diff options
Diffstat (limited to 'BaseTools/Scripts')
-rwxr-xr-x | BaseTools/Scripts/PatchCheck.py | 53 | ||||
-rwxr-xr-x | BaseTools/Scripts/efi_debugging.py | 36 |
2 files changed, 67 insertions, 22 deletions
diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index 83d6795..5c14840 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -97,7 +97,7 @@ class EmailAddressCheck: class CommitMessageCheck:
"""Checks the contents of a git commit message."""
- def __init__(self, subject, message, author_email):
+ def __init__(self, subject, message, author_email, updated_packages):
self.ok = True
self.ignore_multi_package = False
@@ -117,6 +117,7 @@ class CommitMessageCheck: self.check_contributed_under()
if not MergifyMerge:
+ self.check_subject(updated_packages)
self.check_signed_off_by()
self.check_misc_signatures()
self.check_overall_format()
@@ -209,6 +210,14 @@ class CommitMessageCheck: return sigs
+ def check_subject(self, updated_packages):
+ if updated_packages:
+ for package in updated_packages:
+ current_package_re = r"(Revert \"|^|, ?)" + re.escape(package) + r"([ ,:\/])"
+ if not re.search(current_package_re, self.subject):
+ self.error("Subject line not in \"package/component: description\" format!")
+ return
+
def check_signed_off_by(self):
sob='Signed-off-by'
if self.msg.find(sob) < 0:
@@ -254,26 +263,29 @@ class CommitMessageCheck: self.error('Empty commit message!')
return
- if count >= 1 and re.search(self.cve_re, lines[0]):
+ if re.search(self.cve_re, lines[0]):
#
# If CVE-xxxx-xxxxx is present in subject line, then limit length of
# subject line to 92 characters
#
- if len(lines[0].rstrip()) >= 93:
- self.error(
- 'First line of commit message (subject line) is too long (%d >= 93).' %
- (len(lines[0].rstrip()))
- )
+ maxlength = 92
+ elif lines[0].find(':') > 55:
+ #
+ # If we need to enumerate lots of packages, ensure to leave room for
+ # a very short description at the end (after the ':').
+ #
+ maxlength = lines[0].find(':') + 20
else:
#
- # If CVE-xxxx-xxxxx is not present in subject line, then limit
- # length of subject line to 75 characters
+ # Otherwise, limit the length of subject line to 75 characters
#
- if len(lines[0].rstrip()) >= 76:
- self.error(
- 'First line of commit message (subject line) is too long (%d >= 76).' %
- (len(lines[0].rstrip()))
- )
+ maxlength = 75
+
+ if len(lines[0].rstrip()) > maxlength:
+ self.error(
+ 'First line of commit message (subject line) is too long (%d > %d).' %
+ (len(lines[0].rstrip()), maxlength)
+ )
if count >= 1 and len(lines[0].strip()) == 0:
self.error('First line of commit message (subject line) ' +
@@ -485,7 +497,7 @@ class GitDiffCheck: lines = [ msg ]
if self.filename is not None:
lines.append('File: ' + self.filename)
- lines.append('Line: ' + line)
+ lines.append('Line ' + str(self.line_num) + ': ' + line)
self.error(*lines)
@@ -539,7 +551,7 @@ class GitDiffCheck: def format_error(self, err):
self.format_ok = False
err = 'Patch format error: ' + err
- err2 = 'Line: ' + self.lines[self.line_num].rstrip()
+ err2 = 'Line ' + str(self.line_num) + ': ' + self.lines[self.line_num].rstrip()
self.error(err, err2)
def error(self, *err):
@@ -561,14 +573,14 @@ class CheckOnePatch: patch content.
"""
- def __init__(self, name, patch):
+ def __init__(self, name, patch, updated_packages=None):
self.patch = patch
self.find_patch_pieces()
email_check = EmailAddressCheck(self.author_email, 'Author')
email_ok = email_check.ok
- msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg, self.author_email)
+ msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg, self.author_email, updated_packages)
msg_ok = msg_check.ok
self.ignore_multi_package = msg_check.ignore_multi_package
@@ -695,7 +707,8 @@ class CheckGitCommits: email = self.read_committer_email_address_from_git(commit)
self.ok &= EmailAddressCheck(email, 'Committer').ok
patch = self.read_patch_from_git(commit)
- check_patch = CheckOnePatch(commit, patch)
+ updated_packages = self.get_parent_packages (dec_files, commit, 'ADM')
+ check_patch = CheckOnePatch(commit, patch, updated_packages)
self.ok &= check_patch.ok
ignore_multi_package = check_patch.ignore_multi_package
if PatchCheckConf.ignore_multi_package:
@@ -730,7 +743,7 @@ class CheckGitCommits: for dec_file in dec_files:
if os.path.commonpath([dec_file, file]):
dec_found = True
- parents.add(dec_file)
+ parents.add(dec_file.split('/')[0])
if not dec_found and os.path.dirname (file):
# No DEC file found and file is in a subdir
# Covers BaseTools, .github, .azurepipelines, .pytool
diff --git a/BaseTools/Scripts/efi_debugging.py b/BaseTools/Scripts/efi_debugging.py index 9848cd5..1c1446a 100755 --- a/BaseTools/Scripts/efi_debugging.py +++ b/BaseTools/Scripts/efi_debugging.py @@ -33,6 +33,7 @@ import os import uuid
import struct
import re
+import zlib
from ctypes import c_char, c_uint8, c_uint16, c_uint32, c_uint64, c_void_p
from ctypes import ARRAY, sizeof
from ctypes import Structure, LittleEndianStructure
@@ -1770,8 +1771,10 @@ class EfiConfigurationTable: def __init__(self, file, gST_addr=None):
self._file = file
if gST_addr is None:
- # ToDo add code to search for gST via EFI_SYSTEM_TABLE_POINTER
- return
+ # search for gST via EFI_SYSTEM_TABLE_POINTER
+ system_table_pointer = self._get_system_table_pointer()
+ if not system_table_pointer is None:
+ gST_addr = system_table_pointer.EfiSystemTableBase
gST = self._ctype_read(EFI_SYSTEM_TABLE, gST_addr)
self.read_efi_config_table(gST.NumberOfTableEntries,
@@ -1796,6 +1799,35 @@ class EfiConfigurationTable: data = self._file.read(sizeof(ctype_struct))
return ctype_struct.from_buffer(bytearray(data))
+ def _get_system_table_pointer(self):
+ start_addr = 0x0
+ end_addr = 0xf0000000
+ alignment = 0x00400000
+ # The translation of "IBI SYST" for the signature of EFI_SYSTEM_TABLE
+ efi_system_table_signature = 0x5453595320494249
+
+ system_table_pointer = None
+
+ current_addr = start_addr
+ while current_addr < end_addr:
+ try:
+ self._file.seek(current_addr)
+ data = self._file.read(sizeof(EFI_SYSTEM_TABLE_POINTER))
+ except:
+ current_addr = current_addr + alignment
+ continue
+
+ system_table_pointer = EFI_SYSTEM_TABLE_POINTER.from_buffer(bytearray(data))
+ if system_table_pointer.Signature == efi_system_table_signature:
+ buf1 = bytearray(system_table_pointer)[:16]
+ crc32_value = zlib.crc32(buf1)
+ crc32_value = zlib.crc32(b'\0' * (sizeof(EFI_SYSTEM_TABLE_POINTER) - len(buf1)), crc32_value)
+ if crc32_value == system_table_pointer.Crc32:
+ break
+ system_table_pointer = None
+ current_addr = current_addr + alignment
+ return system_table_pointer
+
@ classmethod
def read_efi_config_table(cls, table_cnt, table_ptr, ctype_read):
'''Create a dictionary of EFI Configuration table entries'''
|