Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7d26cd8

Browse files
committed
Merged PR 707: Removing hardcoded address bit width by changing to command line input
Removing hardcoded address bit width by changing to command line input and minor error log improvement
1 parent1e27357 commit7d26cd8

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

‎UefiTestingPkg/AuditTests/PagingAudit/README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ If the USB disk is FS0:\, the files should be in FS1:\\. Copy them to the flash
7878
copy FS1:\*.dat FS0:\
7979
```
8080

81-
On a Windows PC, run the Python script on the data found on your USB key.
81+
On a Windows PC, run Windows\PagingReportGenerator.py script with the data found on your USB key. Please use the following command for detailed script instruction:
82+
```
83+
PagingReportGenerator.py -h
84+
```
8285

8386
Finally, double-click the HTML output file and check your results.
8487

‎UefiTestingPkg/AuditTests/PagingAudit/Windows/BinaryParsing.py‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
importlogging
3131
importcsv
3232

33-
ADDRESS_BITS=0x0000007FFFFFF000
34-
3533
defParseFileToBytes(fileName):
3634
file=open(fileName,"rb")
3735
d=memoryview(file.read())
@@ -50,7 +48,7 @@ def ParseInfoFile(fileName):
5048
returnMemoryRanges
5149

5250

53-
defParse4kPages(fileName):
51+
defParse4kPages(fileName,addressbits):
5452
num=0
5553
pages= []
5654
logging.debug("-- Processing file '%s'..."%fileName)
@@ -64,7 +62,7 @@ def Parse4kPages(fileName):
6462
ReadWrite= ((ByteArray[byteZeroIndex+0]&0x2)>>1)
6563
User= ((ByteArray[byteZeroIndex+0]&0x4)>>2)
6664
# PageTableBaseAddress is 40 bits long
67-
PageTableBaseAddress= (((((ByteArray[byteZeroIndex+1]&0xF0)>>4))+ (ByteArray[byteZeroIndex+2]<<4)+ (ByteArray[byteZeroIndex+3]<<12)+ (ByteArray[byteZeroIndex+4]<<20)+ (ByteArray[byteZeroIndex+5]<<28)+ ((ByteArray[byteZeroIndex+6]&0xF)<<36)<<12)&ADDRESS_BITS)
65+
PageTableBaseAddress= (((((ByteArray[byteZeroIndex+1]&0xF0)>>4))+ (ByteArray[byteZeroIndex+2]<<4)+ (ByteArray[byteZeroIndex+3]<<12)+ (ByteArray[byteZeroIndex+4]<<20)+ (ByteArray[byteZeroIndex+5]<<28)+ ((ByteArray[byteZeroIndex+6]&0xF)<<36)<<12)&addressbits)
6866
Nx= ((ByteArray[byteZeroIndex+7]&0x80)>>7)
6967
ifPresent==0:
7068
raiseException ("Data error")
@@ -76,7 +74,7 @@ def Parse4kPages(fileName):
7674
returnpages
7775

7876

79-
defParse2mPages(fileName):
77+
defParse2mPages(fileName,addressbits):
8078
num=0
8179
pages= []
8280
logging.debug("-- Processing file '%s'..."%fileName)
@@ -91,7 +89,7 @@ def Parse2mPages(fileName):
9189
MustBe1= ((ByteArray[byteZeroIndex+0]&0x80)>>7)
9290
User= ((ByteArray[byteZeroIndex+0]&0x4)>>2)
9391
# PageTableBaseAddress is 31 bits long
94-
PageTableBaseAddress= (((((ByteArray[byteZeroIndex+2]&0xE0)>>5))+ (ByteArray[byteZeroIndex+3]<<3)+ (ByteArray[byteZeroIndex+4]<<11)+ (ByteArray[byteZeroIndex+5]<<19)+ ((ByteArray[byteZeroIndex+6]&0xF)<<27)<<21)&ADDRESS_BITS)
92+
PageTableBaseAddress= (((((ByteArray[byteZeroIndex+2]&0xE0)>>5))+ (ByteArray[byteZeroIndex+3]<<3)+ (ByteArray[byteZeroIndex+4]<<11)+ (ByteArray[byteZeroIndex+5]<<19)+ ((ByteArray[byteZeroIndex+6]&0xF)<<27)<<21)&addressbits)
9593
Nx= ((ByteArray[byteZeroIndex+7]&0x80)>>7)
9694

9795
byteZeroIndex+=8
@@ -101,7 +99,7 @@ def Parse2mPages(fileName):
10199
returnpages
102100

103101

104-
defParse1gPages(fileName):
102+
defParse1gPages(fileName,addressbits):
105103
num=0
106104
pages= []
107105
logging.debug("-- Processing file '%s'..."%fileName)
@@ -116,7 +114,7 @@ def Parse1gPages(fileName):
116114
MustBe1= ((ByteArray[byteZeroIndex+0]&0x80)>>7)
117115
User= ((ByteArray[byteZeroIndex+0]&0x4)>>2)
118116
# PageTableBaseAddress is 22 bits long
119-
PageTableBaseAddress= (((((ByteArray[byteZeroIndex+3]&0xC0)>>6))+ (ByteArray[byteZeroIndex+4]<<2)+ (ByteArray[byteZeroIndex+5]<<10)+ ((ByteArray[byteZeroIndex+6]&0xF)<<18)<<30)&ADDRESS_BITS)# shift and address bits
117+
PageTableBaseAddress= (((((ByteArray[byteZeroIndex+3]&0xC0)>>6))+ (ByteArray[byteZeroIndex+4]<<2)+ (ByteArray[byteZeroIndex+5]<<10)+ ((ByteArray[byteZeroIndex+6]&0xF)<<18)<<30)&addressbits)# shift and address bits
120118
Nx= ((ByteArray[byteZeroIndex+7]&0x80)>>7)
121119

122120
byteZeroIndex+=8

‎UefiTestingPkg/AuditTests/PagingAudit/Windows/MemoryRangeObjects.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ def MemoryRangeToString(self):
149149
------------------------------------------------------------------
150150
Type : %s
151151
PhysicalStart : 0x%010X
152+
PhysicalEnd : 0x%010X
152153
VirtualStart : 0x%010X
153154
NumberOfPages : 0x%010X
154155
Attribute : 0x%010X
155156
PhysicalSize : 0x%010X
156-
"""% (self.GetMemoryTypeDescription(),self.PhysicalStart,self.VirtualStart,self.NumberOfPages,self.Attribute,0)
157+
"""% (self.GetMemoryTypeDescription(),self.PhysicalStart,self.PhysicalEnd,self.VirtualStart,self.NumberOfPages,self.Attribute,self.PhysicalSize)
157158

158159
#
159160
# Intializes memory contents description

‎UefiTestingPkg/AuditTests/PagingAudit/Windows/PagingReportGenerator.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
classParsingTool(object):
4747

48-
def__init__(self,DatFolderPath,PlatformName,PlatformVersion,Type):
48+
def__init__(self,DatFolderPath,PlatformName,PlatformVersion,Type,AddressBits):
4949
self.Logger=logging.getLogger("ParsingTool")
5050
self.MemoryAttributesTable= []
5151
self.MemoryRangeInfo= []
@@ -55,6 +55,7 @@ def __init__(self, DatFolderPath, PlatformName, PlatformVersion, Type):
5555
self.PlatformName=PlatformName
5656
self.PlatformVersion=PlatformVersion
5757
self.Type=Type
58+
self.AddressBits= (1<<AddressBits)-1
5859

5960
defParse(self):
6061
#Get Info Files
@@ -80,13 +81,13 @@ def Parse(self):
8081
self.MemoryRangeInfo.extend(ParseInfoFile(info))
8182

8283
forpte1ginPte1gbFileList:
83-
self.PageDirectoryInfo.extend(Parse1gPages(pte1g))
84+
self.PageDirectoryInfo.extend(Parse1gPages(pte1g,self.AddressBits))
8485

8586
forpte2minPte2mbFileList:
86-
self.PageDirectoryInfo.extend(Parse2mPages(pte2m))
87+
self.PageDirectoryInfo.extend(Parse2mPages(pte2m,self.AddressBits))
8788

8889
forpte4kinPte4kbFileList:
89-
self.PageDirectoryInfo.extend(Parse4kPages(pte4k))
90+
self.PageDirectoryInfo.extend(Parse4kPages(pte4k,self.AddressBits))
9091

9192
forguardpageinGuardPageFileList:
9293
self.PageDirectoryInfo.extend(ParseInfoFile(guardpage))
@@ -209,6 +210,8 @@ def main():
209210
parser.add_argument('-o',"--OutputReport",dest="OutputReport",help="Path to output html report (default is report.html)",default=os.path.join(os.getcwd(),"report.html"))
210211
parser.add_argument('-p',"--PlatformName",dest="PlatformName",help="Name of Platform. Will show up on report",default="Test Platform")
211212
parser.add_argument('-t',"--type",choices=['SMM','DXE'],dest="Type",help="SMM or DXE Paging Report",required=True)
213+
parser.add_argument('-b',"--AddressBits",dest="AddressBits",help="Bit width of CPU address, could be found in processor datasheet or EFI_HOB_TYPE_CPU.\
214+
i.e. For a processor supports 39 bits in address bit width, please pass in '-b 39'",type=int,required=True)
212215
parser.add_argument("--PlatformVersion",dest="PlatformVersion",help="Version of Platform. Will show up report",default="1.0.0")
213216

214217
#Turn on dubug level logging
@@ -248,7 +251,7 @@ def main():
248251
logging.debug("Input Folder Path is: %s"%options.InputFolder)
249252
logging.debug("Output Report is: %s"%options.OutputReport)
250253

251-
spt=ParsingTool(options.InputFolder,options.PlatformName,options.PlatformVersion,options.Type)
254+
spt=ParsingTool(options.InputFolder,options.PlatformName,options.PlatformVersion,options.Type,options.AddressBits)
252255
spt.Parse()
253256
returnspt.OutputHtmlReport(VERSION,options.OutputReport)
254257

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp