Skip to content

Commit 17acb0e

Browse files
committed
Merge branch 'devel-armv8a' into devel-merge-armv8
Commit 161ca81. - Unit tests pass (except mugentau0cmds) o entry point problem - libpaging TEntry problem fixed - Unit tests for mucfgexpand adjusted
2 parents f59c4d9 + 161ca81 commit 17acb0e

File tree

278 files changed

+34455
-1144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+34455
-1144
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ TOOLS = \
3131
mucheckstack \
3232
mugenacpi \
3333
mugenmsrstore \
34+
mugends \
35+
mugendts \
36+
mugenpt \
3437
mugensinfo \
3538
mugensolo5 \
3639
mugenspec \

libmucfgcheck/data/test_policy.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@
277277
<memory alignment="16#1000#" caching="WB" name="linux|acpi_empty" physicalAddress="16#006f_2000#" size="16#c000#" type="subject"/>
278278
<memory alignment="16#1000#" caching="WB" name="linux|lowmem" physicalAddress="16#0fe0_0000#" size="16#0009_b000#" type="subject"/>
279279
<memory alignment="16#1000#" caching="WB" name="linux|bios" physicalAddress="16#006c_2000#" size="16#0001_0000#" type="subject_bios"/>
280+
<memory alignment="16#1000#" caching="WB" name="linux|dtb" physicalAddress="16#2004_0000#" size="16#0004_0000#" type="subject_devicetree">
281+
<file filename="devicetree_linux.dtb" offset="none"/>
282+
</memory>
280283
<memory alignment="16#1000#" caching="WB" name="virtual_time" physicalAddress="16#0fea_b000#" size="16#1000#" type="subject_channel"/>
281284
<memory alignment="16#1000#" caching="WB" name="linux_keyboard" physicalAddress="16#0fea_5000#" size="16#1000#" type="subject_channel"/>
282285
<memory alignment="16#1000#" caching="WB" name="linux_console" physicalAddress="16#006b_2000#" size="16#0001_0000#" type="subject_channel"/>

libmucfgcheck/src/mucfgcheck-device_domains.adb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ with McKae.XML.XPath.XIA;
2323

2424
with Mulog;
2525
with Muxml.Utils;
26+
with Mutools.System_Config;
2627
with Mutools.Types;
2728
with Mutools.Utils;
2829
with Mutools.XML_Utils;
@@ -170,15 +171,23 @@ is
170171

171172
procedure Domain_PT_Region_Presence (XML_Data : Muxml.XML_Data_Type)
172173
is
173-
Domains : constant DOM.Core.Node_List
174+
Domains : constant DOM.Core.Node_List
174175
:= McKae.XML.XPath.XIA.XPath_Query
175176
(N => XML_Data.Doc,
176177
XPath => "/system/deviceDomains/domain");
177178
PT_Regions : constant DOM.Core.Node_List
178179
:= McKae.XML.XPath.XIA.XPath_Query
179180
(N => XML_Data.Doc,
180181
XPath => "/system/memory/memory[@type='system_pt']");
181-
Dom_Count : constant Natural := DOM.Core.Nodes.Length (List => Domains);
182+
Dom_Count : constant Natural := DOM.Core.Nodes.Length (List => Domains);
183+
184+
Is_ARM_System : constant Boolean
185+
:= Mutools.System_Config.Has_Boolean
186+
(Data => XML_Data,
187+
Name => "armv8") and then
188+
Mutools.System_Config.Get_Value
189+
(Data => XML_Data,
190+
Name => "armv8");
182191
begin
183192
Mulog.Log (Msg => "Checking presence of" & Dom_Count'Img
184193
& " security domain PT memory region(s)");
@@ -194,11 +203,13 @@ is
194203
:= DOM.Core.Elements.Get_Attribute
195204
(Elem => Dom_Node,
196205
Name => "name");
206+
Prefix : constant String
207+
:= (if Is_ARM_System then "smmu_" else "vtd_");
197208
PT_Node : constant DOM.Core.Node
198209
:= Muxml.Utils.Get_Element
199210
(Nodes => PT_Regions,
200211
Ref_Attr => "name",
201-
Ref_Value => "vtd_" & Dom_Name & "_pt");
212+
Ref_Value => Prefix & Dom_Name & "_pt");
202213
begin
203214
if PT_Node = null then
204215
Validation_Errors.Insert

libmucfgcheck/src/mucfgcheck-hardware.adb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ is
9898
Validation_Errors.Insert
9999
(Msg => Device_Type & " device '"
100100
& Dev_Name & "' has no memory region");
101-
elsif Mem_Count > 1 then
102-
Validation_Errors.Insert
103-
(Msg => Device_Type & " device '"
104-
& Dev_Name & "' has multiple memory regions");
101+
-- TODO: MOA: SMMU has two iomem regions.
102+
-- elsif Mem_Count > 1 then
103+
-- Validation_Errors.Insert
104+
-- (Msg => Device_Type & " device '"
105+
-- & Dev_Name & "' has multiple memory regions");
105106
end if;
106107
end;
107108
end loop;

libmucfgcheck/src/mucfgcheck-kernel.adb

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -466,29 +466,30 @@ is
466466
Error_Msg => "differs");
467467
end Stack;
468468

469-
Interrupt_Stack :
470-
declare
471-
Nodes : constant DOM.Core.Node_List
472-
:= Muxml.Utils.Get_Elements
473-
(Nodes => Mem_Nodes,
474-
Ref_Attr => "logical",
475-
Ref_Value => "interrupt_stack");
476-
Addr : constant Interfaces.Unsigned_64
477-
:= Interfaces.Unsigned_64'Value
478-
(DOM.Core.Elements.Get_Attribute
479-
(Elem => DOM.Core.Nodes.Item
480-
(List => Nodes,
481-
Index => 0),
482-
Name => "virtualAddress"));
483-
begin
484-
Check_Attribute (Nodes => Nodes,
485-
Node_Type => "kernel interrupt stack memory",
486-
Attr => "virtualAddress",
487-
Name_Attr => "physical",
488-
Test => Equals'Access,
489-
B => Addr,
490-
Error_Msg => "differs");
491-
end Interrupt_Stack;
469+
-- TODO: MOA: No interrupt stack.
470+
-- Interrupt_Stack :
471+
-- declare
472+
-- Nodes : constant DOM.Core.Node_List
473+
-- := Muxml.Utils.Get_Elements
474+
-- (Nodes => Mem_Nodes,
475+
-- Ref_Attr => "logical",
476+
-- Ref_Value => "interrupt_stack");
477+
-- Addr : constant Interfaces.Unsigned_64
478+
-- := Interfaces.Unsigned_64'Value
479+
-- (DOM.Core.Elements.Get_Attribute
480+
-- (Elem => DOM.Core.Nodes.Item
481+
-- (List => Nodes,
482+
-- Index => 0),
483+
-- Name => "virtualAddress"));
484+
-- begin
485+
-- Check_Attribute (Nodes => Nodes,
486+
-- Node_Type => "kernel interrupt stack memory",
487+
-- Attr => "virtualAddress",
488+
-- Name_Attr => "physical",
489+
-- Test => Equals'Access,
490+
-- B => Addr,
491+
-- Error_Msg => "differs");
492+
-- end Interrupt_Stack;
492493
end Stack_Address_Equality;
493494

494495
-------------------------------------------------------------------------

libmucfgcheck/src/mucfgcheck-memory.adb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,60 @@ is
11741174

11751175
-------------------------------------------------------------------------
11761176

1177+
procedure Subject_Linux_Image_Alignment (XML_Data : Muxml.XML_Data_Type)
1178+
is
1179+
Linux_DT : constant Muxml.Utils.Matching_Pairs_Type
1180+
:= Muxml.Utils.Get_Matching
1181+
(XML_Data => XML_Data,
1182+
Left_XPath => "/system/subjects/subject/memory/memory",
1183+
Right_XPath =>
1184+
"/system/memory/memory[@type='subject_devicetree']",
1185+
Match_Multiple => True,
1186+
Match => Mutools.Match.Is_Valid_Reference'Access);
1187+
Physical_SB : constant DOM.Core.Node_List
1188+
:= McKae.XML.XPath.XIA.XPath_Query
1189+
(N => XML_Data.Doc,
1190+
XPath => "/system/memory/memory[@type='subject_binary']");
1191+
begin
1192+
for I in 0 .. DOM.Core.Nodes.Length (List => Linux_DT.Left) - 1 loop
1193+
declare
1194+
Subject : constant DOM.Core.Node
1195+
:= DOM.Core.Nodes.Parent_Node
1196+
(N => DOM.Core.Nodes.Parent_Node
1197+
(N => DOM.Core.Nodes.Item (List => Linux_DT.Left,
1198+
Index => I)));
1199+
Subj_Name : constant String
1200+
:= DOM.Core.Elements.Get_Attribute
1201+
(Elem => Subject,
1202+
Name => "name");
1203+
Subj_Mem : constant DOM.Core.Node_List
1204+
:= McKae.XML.XPath.XIA.XPath_Query
1205+
(N => Subject,
1206+
XPath => "memory/memory");
1207+
Linux_SB : constant Muxml.Utils.Matching_Pairs_Type
1208+
:= Muxml.Utils.Get_Matching
1209+
(Left_Nodes => Subj_Mem,
1210+
Right_Nodes => Physical_SB,
1211+
Match_Multiple => True,
1212+
Match => Mutools.Match.Is_Valid_Reference'Access);
1213+
begin
1214+
Mulog.Log (Msg => "Checking subject binary alignment of Linux "
1215+
& "subject '" & Subj_Name & "'");
1216+
1217+
Check_Attribute (Nodes => Linux_SB.Left,
1218+
Node_Type => "logical memory",
1219+
Attr => "virtualAddress",
1220+
Name_Attr => "logical",
1221+
Test => Mod_Equal_Zero'Access,
1222+
B => 16#0020_0000#,
1223+
Error_Msg => "is not 2MB aligned for Linux "
1224+
& "subject '" & Subj_Name & "'");
1225+
end;
1226+
end loop;
1227+
end Subject_Linux_Image_Alignment;
1228+
1229+
-------------------------------------------------------------------------
1230+
11771231
procedure Subject_MSR_Store_Mappings (XML_Data : Muxml.XML_Data_Type)
11781232
is
11791233
begin

libmucfgcheck/src/mucfgcheck-memory.ads

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ is
221221
--D scheduling partition.
222222
procedure Subject_Sched_Info_Mappings (XML_Data : Muxml.XML_Data_Type);
223223

224+
--D @Item List => validators_mem
225+
--D Validate that Linux subjects have the subject binary properly aligned.
226+
procedure Subject_Linux_Image_Alignment (XML_Data : Muxml.XML_Data_Type);
227+
224228
--D @Item List => validators_mem
225229
--D Validate that subject state, timed event and pending interrupts memory
226230
--D regions are only mapped writable by subjects in the same scheduling group

libmucfgcheck/tests/mucfgcheck-hardware-test_data-tests.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ package body Mucfgcheck.Hardware.Test_Data.Tests is
5252

5353
Memory_Space (XML_Data => Data);
5454
Assert (Condition => Validation_Errors.Contains
55-
(Msg => "Allocated 16#13ed_c000# bytes of physical memory but "
55+
(Msg => "Allocated 16#13f1_c000# bytes of physical memory but "
5656
& "only 16#042a_1000# bytes available by the hardware"),
5757
Message => "Exception mismatch");
5858
-- begin read only

libmucfgcheck/tests/mucfgcheck-kernel-test_data-tests.adb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,25 @@ package body Mucfgcheck.Kernel.Test_Data.Tests is
193193
& "'kernel_stack_1' kernel stack memory element differs"),
194194
Message => "Exception mismatch (1)");
195195

196-
Muxml.Utils.Set_Attribute
197-
(Doc => Data.Doc,
198-
XPath => "/system/kernel/memory/cpu/memory"
199-
& "[@physical='kernel_stack_1']",
200-
Name => "virtualAddress",
201-
Value => "16#0011_3000#");
202-
Muxml.Utils.Set_Attribute
203-
(Doc => Data.Doc,
204-
XPath => "/system/kernel/memory/cpu/memory"
205-
& "[@physical='kernel_interrupt_stack_1']",
206-
Name => "virtualAddress",
207-
Value => "16#0051_0000#");
208-
209-
Stack_Address_Equality (XML_Data => Data);
210-
Assert (Condition => Validation_Errors.Contains
211-
(Msg => "Attribute 'virtualAddress => 16#0051_0000#' of "
212-
& "'kernel_interrupt_stack_1' kernel interrupt stack "
213-
& "memory element differs"),
214-
Message => "Exception mismatch (2)");
196+
-- Muxml.Utils.Set_Attribute
197+
-- (Doc => Data.Doc,
198+
-- XPath => "/system/kernel/memory/cpu/memory"
199+
-- & "[@physical='kernel_stack_1']",
200+
-- Name => "virtualAddress",
201+
-- Value => "16#0011_3000#");
202+
-- Muxml.Utils.Set_Attribute
203+
-- (Doc => Data.Doc,
204+
-- XPath => "/system/kernel/memory/cpu/memory"
205+
-- & "[@physical='kernel_interrupt_stack_1']",
206+
-- Name => "virtualAddress",
207+
-- Value => "16#0051_0000#");
208+
209+
-- Stack_Address_Equality (XML_Data => Data);
210+
-- Assert (Condition => Validation_Errors.Contains
211+
-- (Msg => "Attribute 'virtualAddress => 16#0051_0000#' of "
212+
-- & "'kernel_interrupt_stack_1' kernel interrupt stack "
213+
-- & "memory element differs"),
214+
-- Message => "Exception mismatch (2)");
215215
-- begin read only
216216
end Test_Stack_Address_Equality;
217217
-- end read only

libmucfgcheck/tests/mucfgcheck-memory-test_data-tests.adb

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,79 @@ package body Mucfgcheck.Memory.Test_Data.Tests is
20882088
-- end read only
20892089

20902090

2091+
-- begin read only
2092+
procedure Test_Subject_Linux_Image_Alignment (Gnattest_T : in out Test);
2093+
procedure Test_Subject_Linux_Image_Alignment_086ed4 (Gnattest_T : in out Test) renames Test_Subject_Linux_Image_Alignment;
2094+
-- id:2.2/086ed40c4cee268e/Subject_Linux_Image_Alignment/1/0/
2095+
procedure Test_Subject_Linux_Image_Alignment (Gnattest_T : in out Test) is
2096+
-- end read only
2097+
2098+
pragma Unreferenced (Gnattest_T);
2099+
2100+
Data : Muxml.XML_Data_Type;
2101+
DT : DOM.Core.Node;
2102+
begin
2103+
Muxml.Parse (Data => Data,
2104+
Kind => Muxml.Format_B,
2105+
File => "data/test_policy.xml");
2106+
2107+
-- Add device tree node to Linux subject.
2108+
DT := DOM.Core.Documents.Create_Element
2109+
(Doc => Data.Doc,
2110+
Tag_Name => "memory");
2111+
DOM.Core.Elements.Set_Attribute
2112+
(Elem => DT,
2113+
Name => "executable",
2114+
Value => "true");
2115+
DOM.Core.Elements.Set_Attribute
2116+
(Elem => DT,
2117+
Name => "logical",
2118+
Value => "dtb");
2119+
DOM.Core.Elements.Set_Attribute
2120+
(Elem => DT,
2121+
Name => "physical",
2122+
Value => "linux|dtb");
2123+
DOM.Core.Elements.Set_Attribute
2124+
(Elem => DT,
2125+
Name => "virtualAddress",
2126+
Value => "16#0010_0000#");
2127+
DOM.Core.Elements.Set_Attribute
2128+
(Elem => DT,
2129+
Name => "writable",
2130+
Value => "true");
2131+
2132+
Muxml.Utils.Append_Child
2133+
(Node => Muxml.Utils.Get_Element
2134+
(Doc => Data.Doc,
2135+
XPath => "/system/subjects/subject[@name='linux']/memory"),
2136+
New_Child => DT);
2137+
2138+
-- Positive test, must not raise an exception.
2139+
2140+
Subject_Linux_Image_Alignment (XML_Data => Data);
2141+
Assert (Condition => Validation_Errors.Is_Empty,
2142+
Message => "Unexpected error in positive test");
2143+
2144+
-- Misalign the subject binary of the Linux kernel.
2145+
2146+
Muxml.Utils.Set_Attribute
2147+
(Doc => Data.Doc,
2148+
XPath => "/system/subjects/subject[@name='linux']/memory/memory[@logical='binary']",
2149+
Name => "virtualAddress",
2150+
Value => "16#0008_0000#");
2151+
2152+
Subject_Linux_Image_Alignment (XML_Data => Data);
2153+
Assert (Condition => Validation_Errors.Contains
2154+
(Msg => "Attribute 'virtualAddress => 16#0008_0000#' of "
2155+
& "'binary' logical memory element is not 2MB aligned "
2156+
& "for Linux subject 'linux'"),
2157+
Message => "Exception mismatch");
2158+
2159+
-- begin read only
2160+
end Test_Subject_Linux_Image_Alignment;
2161+
-- end read only
2162+
2163+
20912164
-- begin read only
20922165
procedure Test_Monitor_Subject_Region_Mappings (Gnattest_T : in out Test);
20932166
procedure Test_Monitor_Subject_Region_Mappings_11712e (Gnattest_T : in out Test) renames Test_Monitor_Subject_Region_Mappings;

0 commit comments

Comments
 (0)