diff --git a/.azurepipelines/Ubuntu-GCC5.yml b/.azurepipelines/Ubuntu-GCC5.yml index 367e414499..2199b6a8ac 100644 --- a/.azurepipelines/Ubuntu-GCC5.yml +++ b/.azurepipelines/Ubuntu-GCC5.yml @@ -1,32 +1,40 @@ -## @file -# Azure Pipeline build file for a build using Ubuntu and GCC. -# -# Copyright (c) Microsoft Corporation. -# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent -## - -resources: - repositories: - - repository: mu_devops - type: github - endpoint: microsoft - name: microsoft/mu_devops - ref: main - -variables: -- group: architectures-arm-64-x86-64 -- group: tool-chain-ubuntu-gcc - -jobs: -- template: Matrix-Build-Job.yml - parameters: - arch_list: $(arch_list) - extra_build_args: CODE_COVERAGE=TRUE CC_HTML=TRUE - extra_install_step: - - script: | - sudo apt-get install -y mingw-w64 lcov - pip install lcov_cobertura pycobertura - displayName: Install Windows Resource Compiler for Linux & Code Coverage Tools - tool_chain_tag: $(tool_chain_tag) - vm_image: $(vm_image) +## @file +# Azure Pipeline build file for a build using Ubuntu and GCC. +# +# IMPORTANT: This file requires the local repo to contain a .azurepipelines/Matrix-Build-Job.yml file that +# performs the actual build steps for the configurations and packages supported by the repo. +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +resources: + repositories: + - repository: mu_devops + type: github + endpoint: microsoft + name: microsoft/mu_devops + ref: main + +variables: +- group: architectures-arm-64-x86-64 +- group: tool-chain-ubuntu-gcc + +jobs: +- template: Matrix-Build-Job.yml + parameters: + arch_list: $(arch_list) + extra_build_args: CODE_COVERAGE=TRUE CC_HTML=TRUE + extra_install_step: + - script: | + sudo apt-get install -y mingw-w64 lcov + pip install lcov_cobertura pycobertura + displayName: Install Windows Resource Compiler for Linux & Code Coverage Tools + tool_chain_tag: $(tool_chain_tag) + vm_image: $(vm_image) diff --git a/.azurepipelines/Windows-VS.yml b/.azurepipelines/Windows-VS.yml index 9806316528..1e8357e6b1 100644 --- a/.azurepipelines/Windows-VS.yml +++ b/.azurepipelines/Windows-VS.yml @@ -1,26 +1,34 @@ -## @file -# Azure Pipeline build file for a build using Windows and the latest Visual Studio toolchain supported. -# -# Copyright (c) Microsoft Corporation. -# SPDX-License-Identifier: BSD-2-Clause-Patent -## - -resources: - repositories: - - repository: mu_devops - type: github - endpoint: microsoft - name: microsoft/mu_devops - ref: main - -variables: -- group: architectures-x86-64 -- group: tool-chain-windows-visual-studio-latest - -jobs: -- template: Matrix-Build-Job.yml - parameters: - arch_list: $(arch_list) - tool_chain_tag: $(tool_chain_tag) - vm_image: $(vm_image) - +## @file +# Azure Pipeline build file for a build using Windows and the latest Visual Studio toolchain supported. +# +# IMPORTANT: This file requires the local repo to contain a .azurepipelines/Matrix-Build-Job.yml file that +# performs the actual build steps for the configurations and packages supported by the repo. +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +resources: + repositories: + - repository: mu_devops + type: github + endpoint: microsoft + name: microsoft/mu_devops + ref: main + +variables: +- group: architectures-x86-64 +- group: tool-chain-windows-visual-studio-latest + +jobs: +- template: Matrix-Build-Job.yml + parameters: + arch_list: $(arch_list) + tool_chain_tag: $(tool_chain_tag) + vm_image: $(vm_image) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000000..12b5b4bdab --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,143 @@ +# Project Mu GitHub Bug Report Template +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +name: 🐛 Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["type:bug", "state:needs-triage"] + +body: + - type: markdown + attributes: + value: | + 👋 Thanks for taking the time to fill out this bug report! + + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an issue already exists for the bug you encountered. + options: + - label: I have searched existing issues + required: true + + - type: textarea + id: current_behavior + attributes: + label: Current Behavior + description: A concise description of the bug that you're experiencing. + validations: + required: true + + - type: textarea + id: expected_behavior + attributes: + label: Expected Behavior + description: A concise description of what you expected to happen. + validations: + required: true + + - type: textarea + id: steps_to_reproduce + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + placeholder: | + <example> + 1. In this environment... + 2. With this config... + 3. Boot to '...' + 4. Change option '...' + 4. See error... + validations: + required: true + + - type: textarea + id: build_environment + attributes: + label: Build Environment + description: | + examples: + - **OS**: Ubuntu 20.04 or Windows 11... + - **Tool Chain**: GCC5 or VS2022 or CLANGPDB... + - **Targets Impacted**: RELEASE, DEBUG, NO-TARGET, NOOPT... + value: | + - OS(s): + - Tool Chain(s): + - Targets Impacted: + render: markdown + validations: + required: true + + - type: textarea + id: version_info + attributes: + label: Version Information + description: What version of this repo reproduces the problem? + placeholder: | + Commit: <SHA> + -or- + Tag: <Tag> + render: text + validations: + required: true + + - type: markdown + attributes: + value: | + **Urgency Key** + - 🟢 **Low** + - A minor change with little to no important functional impact + - It is not important to fix this in a specific time frame + - 🟡 **Medium** + - An important change with a functional impact + - Will be prioritized above *low* issues in the normal course of development + - 🔥 **High** + - A critical change that has a significant functional impact + - Must be fixed immediately + + - type: dropdown + id: urgency + attributes: + label: Urgency + description: How urgent is it to fix this bug? + multiple: false + options: + - Low + - Medium + - High + validations: + required: true + + - type: dropdown + id: fix_owner + attributes: + label: Are you going to fix this? + description: Indicate if you are going to fix this or requesting someone else fix it. + multiple: false + options: + - I will fix it + - Someone else needs to fix it + validations: + required: true + + - type: textarea + id: anything_else + attributes: + label: Anything else? + description: | + Links? References? Anything that will give us more context about the issue you are encountering. + + Serial debug logs and/or debugger logs are especially helpful! + + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..f9b067c655 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,20 @@ +# Project Mu GitHub Issue Configuration File +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +contact_links: + - name: 📃 Project Mu Documentation + url: https://microsoft.github.io/mu/ + about: Goals, principles, repo layout, build instructions, and more. + + - name: 🔐 Security Reporting Policy + url: https://github.com/microsoft/.github/blob/main/SECURITY.md + about: A special process is used to report security vulnerabilities. diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml new file mode 100644 index 0000000000..d8ed7cf09a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -0,0 +1,53 @@ +# Project Mu GitHub Documentation Request Template +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +name: 📖 Documentation Request +description: Request a documentation change +title: "[Documentation]: <title>" +labels: ["type:documentation", "state:needs-triage"] + +body: + - type: markdown + attributes: + value: | + 👋 Thanks for taking the time to help us improve our documentation! + + - type: textarea + id: request_description + attributes: + label: Request Description + description: A clear and concise description of what needs to change. + validations: + required: true + + - type: dropdown + id: request_owner + attributes: + label: Are you going to make the change? + description: Indicate if you are going to make this change or requesting someone else make it. + multiple: false + options: + - I will make the change + - Someone else needs to make the change + validations: + required: true + + - type: textarea + id: anything_else + attributes: + label: Anything else? + description: | + Links? References? Anything that will give us more context about the request. + + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000000..28bf8842f2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,96 @@ +# Project Mu GitHub Feature Request Template +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +name: 🚀 Feature Request +description: Request a feature change +title: "[Feature]: <title>" +labels: ["type:feature-request", "state:needs-triage"] + +body: + - type: markdown + attributes: + value: | + 👋 Thanks for taking the time to help us improve our features! + + - type: textarea + id: feature_overview + attributes: + label: Feature Overview + description: Provide a high-level summary of your feature request. + validations: + required: true + + - type: textarea + id: solution_overview + attributes: + label: Solution Overview + description: Give a clear and concise description of what you want to happen. + validations: + required: true + + - type: textarea + id: alternatives_considered + attributes: + label: Alternatives Considered + description: Describe alternatives you've considered. + validations: + required: false + + - type: markdown + attributes: + value: | + **Urgency Key** + - 🟢 **Low** + - A minor enhancement + - It is not important to address this request in a specific time frame + - 🟡 **Medium** + - An important enhancement + - Will be prioritized above *low* requests in the normal course of development + - 🔥 **High** + - A critical enhancement with significant value + - Should be prioritized above *low* and *medium* requests + + - type: dropdown + id: urgency + attributes: + label: Urgency + description: How urgent is it to resolve this feature request? + multiple: false + options: + - Low + - Medium + - High + validations: + required: true + + - type: dropdown + id: request_owner + attributes: + label: Are you going to implement the feature request? + description: Indicate if you are going to do the work to close this feature request. + multiple: false + options: + - I will implement the feature + - Someone else needs to implement the feature + validations: + required: true + + - type: textarea + id: anything_else + attributes: + label: Anything else? + description: | + Links? References? Anything that will give us more context about the feature you are requesting. + + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + validations: + required: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 51a7e915cf..bfd0adc4b7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,18 +2,47 @@ # Dependabot configuration file to enable GitHub services for managing and updating # dependencies. # -# Copyright (c) Microsoft Corporation. All rights reserved. +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# This dependabot file is limited to syncing the following type of dependencies. Other files +# are already available in Mu DevOps to sync other dependency types. +# - GitHub Actions (`github-actions`) +# - Python PIP Modules (`pip`) +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: BSD-2-Clause-Patent # -# Please see the documentation for all configuration options: +# Please see the documentation for all dependabot configuration options: # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates ## + version: 2 + updates: - - package-ecosystem: "pip" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + commit-message: + prefix: "GitHub Action" + labels: + - "type:dependencies" + reviewers: + - "microsoft/project-mu-dependency-reviewers" + + - package-ecosystem: "pip" + directory: "/" schedule: interval: "daily" commit-message: - # Prefix all commit messages with "pip" prefix: "pip" + labels: + - "language:python" + - "type:dependencies" + reviewers: + - "microsoft/project-mu-dependency-reviewers" diff --git a/pull_request_template.md b/.github/pull_request_template.md similarity index 56% rename from pull_request_template.md rename to .github/pull_request_template.md index b66f77c995..1004868c1d 100644 --- a/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,8 +2,14 @@ <_Please include a description of the change and why this change was made._> +For each item, place an "x" in between `[` and `]` if true. Example: `[x]`. +_(you can also check items in the GitHub UI)_ + +- [ ] Impacts functionality? +- [ ] Impacts security? - [ ] Breaking change? - - Will this change break pre-existing builds or functionality without action being taken? +- [ ] Includes tests? +- [ ] Includes documentation? ## How This Was Tested diff --git a/.github/workflows/label-issues.yml b/.github/workflows/label-issues.yml new file mode 100644 index 0000000000..2ad0297809 --- /dev/null +++ b/.github/workflows/label-issues.yml @@ -0,0 +1,34 @@ +# This workflow automatically applies labels to GitHub issues and pull requests based on the +# file paths in a pull request or content in the body of an issue or pull request. +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# NOTE: This file uses a reusable workflow. Do not make changes to the file that should be made +# in the common/reusable workflow. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +name: Apply Issue and PR Labels + +on: + issues: + types: + - edited + - opened + pull_request_target: + types: + - edited + - opened + - reopened + - synchronize + workflow_dispatch: + +jobs: + apply: + uses: microsoft/mu_devops/.github/workflows/Labeler.yml@main diff --git a/.github/workflows/label-issues/file-paths.yml b/.github/workflows/label-issues/file-paths.yml new file mode 100644 index 0000000000..5cd3a7bf61 --- /dev/null +++ b/.github/workflows/label-issues/file-paths.yml @@ -0,0 +1,12 @@ +# Specifies labels to apply to issues and pull requests based on file path patterns in Project Mu repositories. +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# For more information, see: +# https://github.com/actions/labeler + +# Maintenance: Keep labels organized in ascending alphabetical order - easier to scan, identify duplicates, etc. + +language:python: + - '**/*.py' diff --git a/.github/workflows/label-issues/regex-pull-requests.yml b/.github/workflows/label-issues/regex-pull-requests.yml new file mode 100644 index 0000000000..175d3c3eed --- /dev/null +++ b/.github/workflows/label-issues/regex-pull-requests.yml @@ -0,0 +1,24 @@ +# Specifies labels to apply to pull requests in Project Mu repositories based on regular expressions. +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# For more information, see: +# https://github.com/github/issue-labeler + +# Maintenance: Keep labels organized in ascending alphabetical order - easier to scan, identify duplicates, etc. + +impact:breaking-change: + - '\s*-\s*\[\s*[x|X]\s*\] Breaking change\?' + +impact:non-functional: + - '\s*-\s*\[\s*[x|X]\s*\] Impacts functionality\?' + +impact:security: + - '\s*-\s*\[\s*[x|X]\s*\] Impacts security\?' + +impact:testing: + - '\s*-\s*\[\s*[x|X]\s*\] Includes tests\?' + +type:documentation: + - '\s*-\s*\[\s*[x|X]\s*\] Includes documentation\?' diff --git a/.github/workflows/label-sync.yml b/.github/workflows/label-sync.yml new file mode 100644 index 0000000000..e7b493eed1 --- /dev/null +++ b/.github/workflows/label-sync.yml @@ -0,0 +1,27 @@ +# This workflow syncs GitHub labels to the common set of labels defined in Mu DevOps. +# +# All repos should sync at the same time. +# '0 0,12 * * *'' +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +name: Sync GitHub Labels + +on: + schedule: + # At minute 0 past hour 0 and 12 + # https://crontab.guru/#0_0,12_*_*_* + - cron: '0 0,12 * * *' + workflow_dispatch: + +jobs: + sync: + uses: microsoft/mu_devops/.github/workflows/LabelSyncer.yml@main diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000000..043c26b852 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,27 @@ +# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# You can adjust the behavior by modifying this file. +# For more information, see: +# https://github.com/actions/stale + +name: Check for Stale Issues and Pull Requests + +on: + schedule: + # At 23:35 on every day-of-week from Sunday through Saturday + # https://crontab.guru/#35_23_*_*_0-6 + - cron: '35 23 * * 0-6' + workflow_dispatch: + +jobs: + check: + uses: microsoft/mu_devops/.github/workflows/Stale.yml@main diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 83b980f91c..d9ec238b34 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -1,14 +1,21 @@ -## @file -# markdownlint configuration -# -# Copyright (c) Microsoft Corporation -# SPDX-License-Identifier: BSD-2-Clause-Patent -## - -# Rules can be found here: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md -# Config info: https://github.com/DavidAnson/markdownlint#configuration -{ - "default": true, - "MD013": {"line_length": 120, "code_blocks": false, "tables": false}, - "MD033": {"allowed_elements": ["br"]} -} +## @file +# markdownlint configuration +# +# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there +# instead of the file in this repo. +# +# - Mu DevOps Repo: https://github.com/microsoft/mu_devops +# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +# Rules can be found here: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md +# Config info: https://github.com/DavidAnson/markdownlint#configuration + +{ + "default": true, + "MD013": {"line_length": 120, "code_blocks": false, "tables": false}, + "MD033": {"allowed_elements": ["br"]} +} diff --git a/AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.c b/AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.c index 1adb9fa08b..eaf7ee28ad 100644 --- a/AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.c +++ b/AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.c @@ -126,7 +126,7 @@ OnResetNotificationProtocolInstalled ( // Get a pointer to the report status code protocol. // Status = gBS->LocateProtocol ( - &gEfiResetNotificationProtocolGuid, + &gEdkiiPlatformSpecificResetFilterProtocolGuid, NULL, (VOID **)&ResetNotificationProtocol ); @@ -408,7 +408,7 @@ ProcessResetEventRegistration ( // handler and we'll register when the protocol is installed. // Status = gBS->LocateProtocol ( - &gEfiResetNotificationProtocolGuid, + &gEdkiiPlatformSpecificResetFilterProtocolGuid, NULL, (VOID **)&ResetNotificationProtocol ); @@ -436,7 +436,7 @@ ProcessResetEventRegistration ( DEBUG ((DEBUG_ERROR, "%a: failed to create Reset Protocol protocol callback event (%r)\n", __FUNCTION__, Status)); } else { Status = gBS->RegisterProtocolNotify ( - &gEfiResetNotificationProtocolGuid, + &gEdkiiPlatformSpecificResetFilterProtocolGuid, ResetNotificationEvent, &ResetNotificationRegistration ); diff --git a/AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.inf b/AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.inf index 0c1a79720c..ac12d4b710 100644 --- a/AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.inf +++ b/AdvLoggerPkg/AdvancedFileLogger/AdvancedFileLogger.inf @@ -53,7 +53,7 @@ gMuEventPreExitBootServicesGuid [Protocols] - gEfiResetNotificationProtocolGuid ## CONSUMES + gEdkiiPlatformSpecificResetFilterProtocolGuid ## CONSUMES gEfiSimpleFileSystemProtocolGuid ## CONSUMES [Pcd] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..b7df7bff81 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,51 @@ +# Contributing to Project Mu + +Welcome, and thank you for your interest in contributing to Project Mu! + +There are many ways in which you can contribute, beyond writing code. The goal of this document is to provide a +high-level overview of how you can get involved. + +If this is your first time working with Project Mu, please keep in mind that many project details are maintained in +the [Project Mu Documentation](https://microsoft.github.io/mu/). + +## Asking Questions + +Have a question? Rather than opening an issue, please post your question under the `Q&A` category in the `Discussions` +section of the relevant Project Mu GitHub repo. + +## Reporting Issues + +Every Project Mu repo has an `Issues` section. Bug reports, feature requests, and documentation requests can all be +submitted in the issues section. + +### Identify Where to Report + +Project Mu is distributed across multiple repositories. Use features such as issues and discussions in the repository +most relevant to the topic. + +Although we prefer items to be filed in the most relevant repo, if you're unsure which repo is most relevant, the item +can be filed in the [Project Mu Documentation Repo](https://github.com/microsoft/mu) and we will review the request and +move it to the relevant repo if necessary. + +### Look For an Existing Issue + +Before you create a new issue, please do a search in the issues section of the relevant repo to see if the issue or +feature request has already been filed. + +If you find your issue already exists, make relevant comments and add your +[reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place +of a "+1" comment: + +* 👍 - upvote +* 👎 - downvote + +If you cannot find an existing issue that describes your bug or feature, create a new issue using the guidelines below. + +### Follow Your Issue + +Please continue to follow your request after it is submitted to assist with any additional information that might be +requested. + +## Thank You + +Thank you for your interest in Project Mu and taking the time to contribute! diff --git a/LICENSE.txt b/LICENSE.txt index 6de3d8cd88..28acc5270d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -BSD-2-Clause-Patent License - -Copyright (C) Microsoft Corporation. All rights reserved. -SPDX-License-Identifier: BSD-2-Clause-Patent +BSD-2-Clause-Patent License + +Copyright (C) Microsoft Corporation. All rights reserved. +SPDX-License-Identifier: BSD-2-Clause-Patent diff --git a/MfciPkg/MfciDxe/MfciDxe.c b/MfciPkg/MfciDxe/MfciDxe.c index 52331beb65..ffd818e862 100644 --- a/MfciPkg/MfciDxe/MfciDxe.c +++ b/MfciPkg/MfciDxe/MfciDxe.c @@ -652,7 +652,7 @@ ValidateBlobWithXdrCertificates ( if ((PublicKeyData + ALIGN_VALUE (PublicKeyDataLength, 4)) > PublicKeyDataXdrEnd) { DEBUG (( DEBUG_ERROR, - "%a - PcdMfciPkcs7CertBufferXdr size incorrect: PublicKeyData(0x%x) PublicKeyDataLength(0x%x) PublicKeyDataXdrEnd(0x%x)", + "%a - PcdMfciPkcs7CertBufferXdr size incorrect: PublicKeyData(0x%x) PublicKeyDataLength(0x%x) PublicKeyDataXdrEnd(0x%x)\n", __FUNCTION__, PublicKeyData, PublicKeyDataLength, diff --git a/MfciPkg/MfciDxe/Test/MfciMultipleCertsHostTest.c b/MfciPkg/MfciDxe/Test/MfciMultipleCertsHostTest.c index 44cb0a7b7b..7e9c53170b 100644 --- a/MfciPkg/MfciDxe/Test/MfciMultipleCertsHostTest.c +++ b/MfciPkg/MfciDxe/Test/MfciMultipleCertsHostTest.c @@ -193,6 +193,8 @@ MfciMultipleCertificatesShouldParseSingleCert ( EFI_STATUS Status; UINT8 Dummy; + Dummy = 0; + expect_value (ValidateBlob, SignedPolicy, &Dummy); expect_value (ValidateBlob, SignedPolicySize, sizeof (Dummy)); expect_value (ValidateBlob, TrustAnchorCertSize, sizeof (mCert_Trusted_CA)); @@ -314,6 +316,8 @@ MfciMultipleCertificatesShouldCheckInputs ( EFI_STATUS Status; UINT8 Dummy; + Dummy = 0; + Status = ValidateBlobWithXdrCertificates (&Dummy, sizeof (Dummy), NULL, sizeof (mCert_Trusted_CA_Root_xdr)); UT_ASSERT_STATUS_EQUAL (Status, EFI_ABORTED); @@ -355,6 +359,9 @@ MfciMultipleCertificatesShouldCheckGeneralCertificates ( UINT8 Dummy; UINT8 FakeCertificate; + Dummy = 0; + FakeCertificate = 0; + Status = ValidateBlobWithXdrCertificates (&Dummy, sizeof (Dummy), &FakeCertificate, sizeof (FakeCertificate)); UT_ASSERT_STATUS_EQUAL (Status, EFI_ABORTED); @@ -385,6 +392,9 @@ MfciMultipleCertificatesShouldCheckIndividualCertificate ( { EFI_STATUS Status; UINT8 Dummy; + + Dummy = 0; + // Not enough for individual size field UINT8 FakeCertificate1[] = { 0x00, 0x01, 0x02, 0x03, 0x04 }; // No content individual certificate diff --git a/MsCorePkg/AcpiRGRT/AcpiRgrt.c b/MsCorePkg/AcpiRGRT/AcpiRgrt.c index ad863d5f26..153346f942 100644 --- a/MsCorePkg/AcpiRGRT/AcpiRgrt.c +++ b/MsCorePkg/AcpiRGRT/AcpiRgrt.c @@ -52,6 +52,8 @@ InstallAcpiTable ( UINT32 RgrtTableSize; UINT64 OemTableId; + RgrtAcpiTable = NULL; + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTable); if (EFI_ERROR (Status)) { // we are expected to be called at least once before ACPI is installed diff --git a/MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.c b/MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.c index ee1b5b9897..de01e9406d 100644 --- a/MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.c +++ b/MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.c @@ -23,9 +23,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/ResetSystemLib.h> #include <Library/MsWheaEarlyStorageLib.h> #include <Library/PeCoffGetEntryPointLib.h> +#include <Library/PcdLib.h> -#define IA32_PF_EC_ID BIT4 -#define EXCEPT_STACK_COOKIE 0x40 +#define IA32_PF_EC_ID BIT4 STATIC EFI_HANDLE mImageHandle = NULL; @@ -202,7 +202,7 @@ CpuArchRegisterMemoryProtectionExceptionHandler ( Status = mCpu->RegisterInterruptHandler ( mCpu, - EXCEPT_STACK_COOKIE, + PcdGet8 (PcdStackCookieExceptionVector), MemoryProtectionStackCookieFailureHandler ); diff --git a/MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.inf b/MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.inf index b17aec94a1..aeb8bdcc94 100644 --- a/MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.inf +++ b/MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.inf @@ -39,6 +39,7 @@ HwResetSystemLib MsWheaEarlyStorageLib PeCoffGetEntryPointLib + PcdLib [Guids] gMemoryProtectionExceptionHandlerGuid ## PRODUCES @@ -49,5 +50,8 @@ [Guids] gMemoryProtectionExceptionHandlerGuid +[FixedPcd] + gEfiMdePkgTokenSpaceGuid.PcdStackCookieExceptionVector + [DEPEX] TRUE diff --git a/MsCorePkg/Library/PlatformBootManagerLib/BdsPlatform.h b/MsCorePkg/Library/PlatformBootManagerLib/BdsPlatform.h index 6e4d4fe3a7..621e22b98f 100644 --- a/MsCorePkg/Library/PlatformBootManagerLib/BdsPlatform.h +++ b/MsCorePkg/Library/PlatformBootManagerLib/BdsPlatform.h @@ -47,8 +47,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define gPciRootBridge \ { \ - ACPI_DEVICE_PATH, ACPI_DP, (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \ - ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8), EISA_PNP_ID (0x0A03), 0 \ + { \ + ACPI_DEVICE_PATH, ACPI_DP, \ + { \ + (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \ + ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \ + } \ + }, \ + EISA_PNP_ID (0x0A03), 0 \ } #define gEndEntire \ diff --git a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c index 5a49a9c019..0614092d06 100644 --- a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c +++ b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/Dxe/App/DxePagingAuditTestApp.c @@ -1,5 +1,6 @@ /** @file -- DxePagingAuditTestApp.c -This Shell App writes page table and memory map information to SFS. +This Shell App tests the page table or writes page table and +memory map information to SFS Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -8,10 +9,145 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "../../PagingAuditCommon.h" +#include <Library/UnitTestLib.h> +#include <Library/CpuPageTableLib.h> +#include <Library/DxeMemoryProtectionHobLib.h> +#include <Protocol/MemoryProtectionSpecialRegionProtocol.h> +#include <Protocol/ShellParameters.h> +#include <Protocol/Shell.h> + +#define UNIT_TEST_APP_NAME "Paging Audit Test" +#define UNIT_TEST_APP_VERSION "1" +#define MAX_CHARS_TO_READ 3 + +// TRUE if A interval subsumes B interval +#define CHECK_SUBSUMPTION(AStart, AEnd, BStart, BEnd) \ + ((AStart <= BStart) && (AEnd >= BEnd)) + +typedef struct _PAGING_AUDIT_TEST_CONTEXT { + IA32_MAP_ENTRY *Entries; + UINTN Count; +} PAGING_AUDIT_TEST_CONTEXT; + CHAR8 *mMemoryInfoDatabaseBuffer = NULL; UINTN mMemoryInfoDatabaseSize = 0; UINTN mMemoryInfoDatabaseAllocSize = 0; +/** + Check the page table for Read/Write/Execute regions. + + @param[in] Context Unit test context + + @retval UNIT_TEST_PASSED The unit test passed + @retval other The unit test failed + +**/ +UNIT_TEST_STATUS +EFIAPI +NoReadWriteExcecute ( + IN UNIT_TEST_CONTEXT Context + ) +{ + IA32_MAP_ENTRY *Map = ((PAGING_AUDIT_TEST_CONTEXT *)Context)->Entries; + UINTN MapCount = ((PAGING_AUDIT_TEST_CONTEXT *)Context)->Count; + UINTN Index = 0; + BOOLEAN FoundRWXAddress = FALSE; + BOOLEAN IgnoreRWXAddress = FALSE; + MEMORY_PROTECTION_DEBUG_PROTOCOL *MemoryProtectionProtocol = NULL; + MEMORY_PROTECTION_SPECIAL_REGION_PROTOCOL *SpecialRegionProtocol = NULL; + MEMORY_PROTECTION_SPECIAL_REGION *SpecialRegions = NULL; + UINTN SpecialRegionCount = 0; + UINTN SpecialRegionIndex = 0; + IMAGE_RANGE_DESCRIPTOR *NonProtectedImageList = NULL; + LIST_ENTRY *NonProtectedImageLink = NULL; + IMAGE_RANGE_DESCRIPTOR *NonProtectedImage = NULL; + + UT_ASSERT_NOT_EFI_ERROR ( + gBS->LocateProtocol ( + &gMemoryProtectionDebugProtocolGuid, + NULL, + (VOID **)&MemoryProtectionProtocol + ) + ); + + UT_ASSERT_NOT_EFI_ERROR ( + MemoryProtectionProtocol->GetImageList ( + &NonProtectedImageList, + NonProtected + ) + ); + + UT_ASSERT_NOT_EFI_ERROR ( + gBS->LocateProtocol ( + &gMemoryProtectionSpecialRegionProtocolGuid, + NULL, + (VOID **)&SpecialRegionProtocol + ) + ); + + UT_ASSERT_NOT_EFI_ERROR ( + SpecialRegionProtocol->GetSpecialRegions ( + &SpecialRegions, + &SpecialRegionCount + ) + ); + + for ( ; Index < MapCount; Index++) { + if ((Map[Index].Attribute.Bits.ReadWrite != 0) && (Map[Index].Attribute.Bits.Nx == 0)) { + IgnoreRWXAddress = FALSE; + if (NonProtectedImageList != NULL) { + for (NonProtectedImageLink = NonProtectedImageList->Link.ForwardLink; + NonProtectedImageLink != &NonProtectedImageList->Link; + NonProtectedImageLink = NonProtectedImageLink->ForwardLink) + { + NonProtectedImage = CR ( + NonProtectedImageLink, + IMAGE_RANGE_DESCRIPTOR, + Link, + IMAGE_RANGE_DESCRIPTOR_SIGNATURE + ); + if CHECK_SUBSUMPTION ( + NonProtectedImage->Base, + NonProtectedImage->Base + NonProtectedImage->Length, + Map[Index].LinearAddress, + Map[Index].LinearAddress + Map[Index].Length + ) { + IgnoreRWXAddress = TRUE; + break; + } + } + } + + if ((SpecialRegionCount > 0) && !IgnoreRWXAddress) { + for (SpecialRegionIndex = 0; SpecialRegionIndex < SpecialRegionCount; SpecialRegionIndex++) { + if (CHECK_SUBSUMPTION ( + SpecialRegions[SpecialRegionIndex].Start, + SpecialRegions[SpecialRegionIndex].Start + SpecialRegions[SpecialRegionIndex].Length, + Map[Index].LinearAddress, + Map[Index].LinearAddress + Map[Index].Length + ) && + (SpecialRegions[SpecialRegionIndex].EfiAttributes == 0)) + { + IgnoreRWXAddress = TRUE; + break; + } + } + } + + if (!IgnoreRWXAddress) { + UT_LOG_ERROR ("Memory Range 0x%llx-0x%llx is Read/Write/Execute\n", Map[Index].LinearAddress, Map[Index].LinearAddress + Map[Index].Length); + FoundRWXAddress = TRUE; + } else { + UT_LOG_WARNING ("Memory Range 0x%llx-0x%llx is Read/Write/Execute. This range is excepted from the test.\n", Map[Index].LinearAddress, Map[Index].LinearAddress + Map[Index].Length); + } + } + } + + UT_ASSERT_FALSE (FoundRWXAddress); + + return UNIT_TEST_PASSED; +} + /** DxePagingAuditTestAppEntryPoint @@ -29,7 +165,129 @@ DxePagingAuditTestAppEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { - DumpPagingInfo (NULL, NULL); + EFI_STATUS Status; + UNIT_TEST_FRAMEWORK_HANDLE Fw = NULL; + UNIT_TEST_SUITE_HANDLE Misc = NULL; + PAGING_AUDIT_TEST_CONTEXT *Context; + IA32_CR4 Cr4; + PAGING_MODE PagingMode; + IA32_MAP_ENTRY *Map = NULL; + UINTN MapCount = 0; + UINTN PagesAllocated = 0; + BOOLEAN RunTests = TRUE; + EFI_SHELL_PARAMETERS_PROTOCOL *ShellParams; + + DEBUG ((DEBUG_ERROR, "%a()\n", __FUNCTION__)); + + DEBUG ((DEBUG_ERROR, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION)); + + Status = gBS->HandleProtocol ( + gImageHandle, + &gEfiShellParametersProtocolGuid, + (VOID **)&ShellParams + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a Could not retrieve command line args!\n", __FUNCTION__)); + return EFI_PROTOCOL_ERROR; + } + + if (ShellParams->Argc > 1) { + RunTests = FALSE; + if (StrnCmp (ShellParams->Argv[1], L"-r", 4) == 0) { + RunTests = TRUE; + } else if (StrnCmp (ShellParams->Argv[1], L"-d", 4) == 0) { + DumpPagingInfo (NULL, NULL); + } else { + if (StrnCmp (ShellParams->Argv[1], L"-h", 4) != 0) { + DEBUG ((DEBUG_INFO, "Invalid argument!\n")); + } + + DEBUG ((DEBUG_INFO, "-h : Print available flags\n")); + DEBUG ((DEBUG_INFO, "-d : Dump the page table files to the EFI partition\n")); + DEBUG ((DEBUG_INFO, "-r : Run the application tests\n")); + DEBUG ((DEBUG_INFO, "NOTE: Combined flags (i.e. -rd) is not supported\n")); + } + } + + if (RunTests) { + Context = (PAGING_AUDIT_TEST_CONTEXT *)AllocateZeroPool (sizeof (PAGING_AUDIT_TEST_CONTEXT)); + + if (Context == NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate test context\n")); + goto EXIT; + } + + // + // Start setting up the test framework for running the tests. + // + Status = InitUnitTestFramework (&Fw, UNIT_TEST_APP_NAME, gEfiCallerBaseName, UNIT_TEST_APP_VERSION); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status)); + goto EXIT; + } + + // Poll CR4 to deterimine the page table depth + Cr4.UintN = AsmReadCr4 (); + + if (Cr4.Bits.LA57 != 0) { + PagingMode = Paging5Level; + } else { + PagingMode = Paging4Level; + } + + // CR3 is the page table pointer + Status = PageTableParse (AsmReadCr3 (), PagingMode, NULL, &MapCount); + + while (Status == RETURN_BUFFER_TOO_SMALL) { + if ((Map != NULL) && (PagesAllocated > 0)) { + FreePages (Map, PagesAllocated); + } + + PagesAllocated = EFI_SIZE_TO_PAGES (MapCount * sizeof (IA32_MAP_ENTRY)); + Map = AllocatePages (PagesAllocated); + + if (Map == NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate page table map\n")); + goto EXIT; + } + + Status = PageTableParse (AsmReadCr3 (), PagingMode, Map, &MapCount); + } + + Context->Entries = Map; + Context->Count = MapCount; + + // + // Create test suite + // + CreateUnitTestSuite (&Misc, Fw, "Miscellaneous tests", "Security.Misc", NULL, NULL); + + if (Misc == NULL) { + DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for TestSuite\n")); + goto EXIT; + } + + AddTestCase (Misc, "No pages can be read,write,execute", "Security.Misc.NoReadWriteExecute", NoReadWriteExcecute, NULL, NULL, Context); + + // + // Execute the tests. + // + Status = RunAllTestSuites (Fw); +EXIT: + + if (Fw) { + FreeUnitTestFramework (Fw); + } + + if ((Map != NULL) && (PagesAllocated > 0)) { + FreePages (Map, PagesAllocated); + } + + if (Context != NULL) { + FreePool (Context); + } + } return EFI_SUCCESS; -} // DxePagingAuditTestAppEntryPoint() +} // DxePagingAuditTestAppEntryPoint() diff --git a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/DxePagingAuditTestApp.inf b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/DxePagingAuditTestApp.inf index 57f8b1a67f..d13080adc4 100644 --- a/UefiTestingPkg/AuditTests/PagingAudit/UEFI/DxePagingAuditTestApp.inf +++ b/UefiTestingPkg/AuditTests/PagingAudit/UEFI/DxePagingAuditTestApp.inf @@ -44,6 +44,9 @@ UefiCpuLib HobLib DxeServicesTableLib + UnitTestLib + CpuPageTableLib + DxeMemoryProtectionHobLib [Guids] gEfiDebugImageInfoTableGuid ## SOMETIMES_CONSUMES ## GUID @@ -53,6 +56,8 @@ gEfiBlockIoProtocolGuid gMemoryProtectionDebugProtocolGuid gEfiSimpleFileSystemProtocolGuid + gMemoryProtectionSpecialRegionProtocolGuid + gEfiShellParametersProtocolGuid [FixedPcd] gUefiTestingPkgTokenSpaceGuid.PcdPlatformSmrrUnsupported ## SOMETIMES_CONSUMES diff --git a/UefiTestingPkg/UefiTestingPkg.dsc b/UefiTestingPkg/UefiTestingPkg.dsc index fefdd110e1..445741fbe6 100644 --- a/UefiTestingPkg/UefiTestingPkg.dsc +++ b/UefiTestingPkg/UefiTestingPkg.dsc @@ -58,6 +58,7 @@ PlatformSmmProtectionsTestLib|UefiTestingPkg/Library/PlatformSmmProtectionsTestLibNull/PlatformSmmProtectionsTestLibNull.inf ExceptionPersistenceLib|MdeModulePkg/Library/BaseExceptionPersistenceLibNull/BaseExceptionPersistenceLibNull.inf CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf + DxeMemoryProtectionHobLib|MdeModulePkg/Library/MemoryProtectionHobLibNull/DxeMemoryProtectionHobLibNull.inf [LibraryClasses.common.DXE_SMM_DRIVER] SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf diff --git a/pip-requirements.txt b/pip-requirements.txt index 752cc3e6c8..5d8eb18c4a 100644 --- a/pip-requirements.txt +++ b/pip-requirements.txt @@ -12,8 +12,8 @@ # https://www.python.org/dev/peps/pep-0440/#version-specifiers ## -edk2-pytool-library~=0.11.6 -edk2-pytool-extensions~=0.19.1 +edk2-pytool-library==0.12.1 +edk2-pytool-extensions==0.20.0 edk2-basetools==0.1.29 antlr4-python3-runtime==4.11.1 regex==2022.10.31