Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2598
-gerrit
commit fcd8a6c3c5080464a16bcf939dc31bc9210b319a
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Wed Mar 6 20:19:27 2013 +0200
Refactor matching filters to actions
Each hooks list has some criteria when an action matches a filter.
For memory and IO, the action address must be within the range
of an enabled filter.
For CPUID and MSR, the filter must be enabled, and the filter
internally checks the index parameters.
Change-Id: I6f035a0a39d1f94dc77e1b1dc16459b071ca871a
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/hooks.lua | 56 ++++++++++++++++++++++-------------------------
1 file changed, 26 insertions(+), 30 deletions(-)
diff --git a/SerialICE/simba/hooks.lua b/SerialICE/simba/hooks.lua
index 4a0d529..8877cd7 100644
--- a/SerialICE/simba/hooks.lua
+++ b/SerialICE/simba/hooks.lua
@@ -3,8 +3,8 @@
froot = { id = 0, name = "SerialICE" }
fresource = { id = 1, name = "Resource" }
-function new_hooks(str)
- return { list = nil, name = str }
+function new_hooks(str, rule)
+ return { list = nil, name = str, match_filter = rule }
end
next_filter_id = 2
@@ -21,12 +21,22 @@ function new_parent_action()
current_parent_id = action_id()
end
+function filter_in_range(f, action)
+ if f.enable and action.addr >= f.base and action.addr < f.base + f.size then
+ return true
+ end
+ return false
+end
+
+function filter_enabled(f, action)
+ return f.enable
+end
-io_hooks = new_hooks("IO")
-mem_hooks = new_hooks("MEM")
+io_hooks = new_hooks("IO", filter_in_range)
+mem_hooks = new_hooks("MEM", filter_in_range)
-cpumsr_hooks = new_hooks("CPU MSR")
-cpuid_hooks = new_hooks("CPUID")
+cpumsr_hooks = new_hooks("CPU MSR", filter_enabled)
+cpuid_hooks = new_hooks("CPUID", filter_enabled)
function enable_hook(list, filter)
if not filter then
@@ -76,21 +86,14 @@ function walk_pre_hooks(list, action)
local l = list.list
local f = nil
- local no_base_check = true
- if list == io_hooks or list == mem_hooks then
- no_base_check = false
- end
-
while l and not logged do
f = l.hook
- if no_base_check or action.addr >= f.base and action.addr < f.base + f.size then
- if f.enable and f.pre then
- if f.pre(f, action) then
- if not f.raw then
- action.logged_pre = f
- end
- logged = true
+ if list.match_filter(f, action) then
+ if f.pre and f.pre(f, action) then
+ if not f.raw then
+ action.logged_pre = f
end
+ logged = true
end
end
l = l.next
@@ -113,21 +116,14 @@ function walk_post_hooks(list, action)
local l = list.list
local f = nil
- local no_base_check = true
- if list == io_hooks or list == mem_hooks then
- no_base_check = false
- end
-
while l and not logged do
f = l.hook
- if no_base_check or action.addr >= f.base and action.addr < f.base + f.size then
- if f.enable and f.post then
- if f.post(f, action) then
- if not f.raw then
- action.logged_post = f
- end
- logged = false
+ if list.match_filter(f, action) then
+ if f.post and f.post(f, action) then
+ if not f.raw then
+ action.logged_post = f
end
+ logged = false
end
end
l = l.next
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2597
-gerrit
commit 10c41b5ed7c5718821bde96903e4a97fd12cf241
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Tue Mar 5 09:40:28 2013 +0200
Only log Raw action lines from Qemu session
The only lines a qemu session with SerialICE needs to write in the
output are those produced with the core filters and marked with the
flag Raw "R...". Everything else can be replayed from these.
This is a principal change: the output of Qemu session is now completely
raw and one must pass the logfile thru replayer to have simplified view.
Change-Id: I6e4eebde41ca46072c545c02eabac848113bb5ee
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/core_io.lua | 4 ++--
SerialICE/simba/cpu.lua | 4 +++-
SerialICE/simba/hooks.lua | 24 ++++++++++++------------
SerialICE/simba/output.lua | 37 +++++++++++++++++++++++++++++++------
SerialICE/simba/replay.lua | 9 +--------
SerialICE/simba/serialice.lua | 4 ++--
SerialICE/simba/smbus_host.lua | 1 -
7 files changed, 51 insertions(+), 32 deletions(-)
diff --git a/SerialICE/simba/core_io.lua b/SerialICE/simba/core_io.lua
index 0aa67fd..08ae42e 100644
--- a/SerialICE/simba/core_io.lua
+++ b/SerialICE/simba/core_io.lua
@@ -8,7 +8,6 @@ F_RANGE = 2
function io_undefined(f, action)
action.to_hw = true
action.to_qemu = false
- action.undefined = true
return true
end
@@ -32,6 +31,7 @@ end
filter_io_fallback = {
name = "IO",
+ raw = true,
pre = io_undefined,
post = io_post,
decode = F_FIXED,
@@ -45,7 +45,6 @@ filter_io_fallback = {
function mem_undefined(f, action)
action.to_hw = true
action.to_qemu = false
- action.undefined = true
return true
end
@@ -69,6 +68,7 @@ end
filter_mem_fallback = {
name = "MEM",
+ raw = true,
pre = mem_undefined,
post = mem_post,
decode = F_FIXED,
diff --git a/SerialICE/simba/cpu.lua b/SerialICE/simba/cpu.lua
index 6dad741..02839a9 100644
--- a/SerialICE/simba/cpu.lua
+++ b/SerialICE/simba/cpu.lua
@@ -72,6 +72,7 @@ end
filter_cpumsr_fallback = {
name = "CPU MSR",
+ raw = true,
pre = cpumsr_pre,
post = cpumsr_post,
}
@@ -96,6 +97,7 @@ end
filter_cpuid_fallback = {
name = "CPUID",
+ raw = true,
pre = cpuid_pre,
post = cpuid_post,
}
@@ -114,7 +116,7 @@ function multicore_post(f, action)
if not action.write and rin.eax == 0x01 then
rout.ebx = bit32.band(0xff00ffff, rout.ebx);
rout.ebx = bit32.bor(0x00010000, rout.ebx);
- fake_action(f, action, 0)
+ return fake_action(f, action, 0)
end
return skip_filter(f, action)
end
diff --git a/SerialICE/simba/hooks.lua b/SerialICE/simba/hooks.lua
index 01aea65..4a0d529 100644
--- a/SerialICE/simba/hooks.lua
+++ b/SerialICE/simba/hooks.lua
@@ -85,12 +85,16 @@ function walk_pre_hooks(list, action)
f = l.hook
if no_base_check or action.addr >= f.base and action.addr < f.base + f.size then
if f.enable and f.pre then
- logged = f.pre(f, action)
+ if f.pre(f, action) then
+ if not f.raw then
+ action.logged_pre = f
+ end
+ logged = true
+ end
end
end
l = l.next
end
-
if prev_filter ~= f and not action.ignore then
prev_filter = f
new_parent_action()
@@ -118,15 +122,11 @@ function walk_post_hooks(list, action)
f = l.hook
if no_base_check or action.addr >= f.base and action.addr < f.base + f.size then
if f.enable and f.post then
- if no_base_check then
- -- cpuid or cpumsr
- logged = f.post(f, action)
- else
- -- io or mem
- if f.post(f, action) then
- action.f = f
- logged = f.hide and not log_everything
+ if f.post(f, action) then
+ if not f.raw then
+ action.logged_post = f
end
+ logged = false
end
end
end
@@ -218,9 +218,9 @@ function pre_action(action, dir_wr, addr, size, data)
action.my_id = 0
-- no filter, not filtered
- action.f = nil
+ action.logged_pre = nil
+ action.logged_post = nil
action.ignore = false
- action.undefined = false
action.faked = false
action.dropped = false
action.to_hw = false
diff --git a/SerialICE/simba/output.lua b/SerialICE/simba/output.lua
index 10977ea..889dcc1 100644
--- a/SerialICE/simba/output.lua
+++ b/SerialICE/simba/output.lua
@@ -12,7 +12,21 @@ end
function printk(f, action, fmt, ...)
local str = ""
- if action.undefined or action.f or action == cpu_action then
+
+ -- For Qemu runs only Raw actions are logged
+ if not replaying and not f.raw then
+ return
+ end
+
+ -- For replays, a post filter prevents further lines for the
+ -- same action from printing if it has property hide set.
+ if replaying and not log_everything then
+ if action.logged_post and action.logged_post.hide then
+ return
+ end
+ end
+
+ if f.raw then
str = str .. "R"
elseif action.info_only then
str = str .. "I"
@@ -29,7 +43,7 @@ function printk(f, action, fmt, ...)
else
str = str .. "."
end
- if action.undefined then
+ if f.raw and not (action.logged_pre or action.logged_post) then
str = str .. "U"
elseif action.dropped then
str = str .. "D"
@@ -41,12 +55,23 @@ function printk(f, action, fmt, ...)
print_address(action.parent_id, action.my_id, str, action.cs, action.eip)
- if action.f then
- printf("%s,%s: ", f.name, action.f.name)
- printf(fmt, ...)
- else
+ if not replaying then
printf("%s: ", f.name)
printf(fmt, ...)
+ else
+ if not f.raw then
+ printf("%s: ", f.name)
+ printf(fmt, ...)
+ elseif action.logged_post then
+ printf("%s: ", action.logged_post.name)
+ printf(fmt, ...)
+ elseif action.logged_pre then
+ printf("%s: ", action.logged_pre.name)
+ printf(fmt, ...)
+ else
+ printf("%s: ", f.name)
+ printf(fmt, ...)
+ end
end
end
diff --git a/SerialICE/simba/replay.lua b/SerialICE/simba/replay.lua
index 3ac0434..4632c05 100644
--- a/SerialICE/simba/replay.lua
+++ b/SerialICE/simba/replay.lua
@@ -1,5 +1,5 @@
-local verbose_log = false
+replaying = true
function SerialICE_register_physical()
end
@@ -176,8 +176,6 @@ function parse_headers()
found, _, board = string.find(line, "SerialICE: Mainboard...:%s+(.+)")
if found then
SerialICE_mainboard = board
- io.write(line)
- io.write("\n")
end
end
if string.find(line, "LUA script initialized.") then
@@ -267,11 +265,6 @@ function parse_file()
end
parse_headers()
-
dofile("serialice.lua")
-
--- set logging
-log_everything = verbose_log
-
parse_file()
diff --git a/SerialICE/simba/serialice.lua b/SerialICE/simba/serialice.lua
index 7cabf67..434556f 100644
--- a/SerialICE/simba/serialice.lua
+++ b/SerialICE/simba/serialice.lua
@@ -68,6 +68,8 @@ dofile("pc80.lua")
dofile("superio.lua")
dofile("mmio.lua")
+io.write("SerialICE: LUA script initialized.\n")
+
function do_minimal_setup()
enable_hook(io_hooks, filter_io_fallback)
enable_hook(mem_hooks, filter_mem_fallback)
@@ -106,7 +108,5 @@ else
do_default_setup()
end
-root_info("LUA script initialized.\n")
-
return true
diff --git a/SerialICE/simba/smbus_host.lua b/SerialICE/simba/smbus_host.lua
index a407843..161bc42 100644
--- a/SerialICE/simba/smbus_host.lua
+++ b/SerialICE/simba/smbus_host.lua
@@ -186,7 +186,6 @@ local function dump_transaction(f, action)
end
if signal_in(f, SIG_TIMEOUT) then
- action.undefined = true
dump = dump .. " (TIMEOUT) "
end
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2596
-gerrit
commit abf616c01e81c21084fe7112cd6a4f1545b6c268
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Wed Mar 6 20:00:11 2013 +0200
Fix variable MTRR filter
Separate this from the MSR fallback filter.
This filter is not enabled by default and was actually
broken because it did not check correctly for the MSR index.
Change-Id: I83caabe38070bf45a534585f1243bc2fe9f0c724
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/cpu.lua | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/SerialICE/simba/cpu.lua b/SerialICE/simba/cpu.lua
index 22ccb33..6dad741 100644
--- a/SerialICE/simba/cpu.lua
+++ b/SerialICE/simba/cpu.lua
@@ -2,11 +2,14 @@
-- CPU MSR filters
function var_mtrr_post(f, action)
-
local addr = action.rin.ecx
local hi = action.rin.edx
local lo = action.rin.eax
+ if not action.write then
+ return true
+ end
+
if addr % 2 == 0 then
mt = lo % 0x100
if mt == 0 then memtype = "Uncacheable"
@@ -25,8 +28,32 @@ function var_mtrr_post(f, action)
end
printk(f, action, "Set MTRR %x mask to %08x.%08x (%s)\n", (addr - 0x200) / 2, hi, bit32.band(lo, 0xfffff000), valid)
end
+ return true
+end
+
+function mtrr_pre(f, action)
+ local addr = action.rin.ecx
+ if addr >= 0x200 and addr < 0x210 then
+ return handle_action(f, action)
+ end
+ return false
end
+function mtrr_post(f, action)
+ local addr = action.rin.ecx
+ if addr >= 0x200 and addr < 0x210 then
+ return var_mtrr_post(f, action)
+ end
+ return false
+end
+
+filter_mtrr = {
+ name = "MTRR",
+ pre = mtrr_pre,
+ post = mtrr_post,
+ hide = true,
+}
+
function cpumsr_pre(f, action)
return handle_action(f, action)
end
@@ -35,9 +62,6 @@ function cpumsr_post(f, action)
if action.write then
printk(f, action, "[%08x] <= %08x.%08x\n",
action.rin.ecx, action.rin.edx, action.rin.eax)
- if action.addr >= 0x200 and action.addr < 0x210 then
- var_mtrr_post(f, action)
- end
else
printk(f, action, "[%08x] => %08x.%08x\n",
action.rin.ecx, action.rout.edx, action.rout.eax)
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2595
-gerrit
commit 32d7438bc4086c2a120b4b429a7e6c471d65072b
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Wed Mar 6 19:53:09 2013 +0200
Fix flag combinations
In some rare case writes go to both hardware and qemu,
so put those at different columns.
Only one of "Undefined, Dropped or Faked" is possible
at a time, place them on same column.
Change-Id: I9b891e44ca1f044c68c21021599fa3a0f8dbae9e
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/output.lua | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/SerialICE/simba/output.lua b/SerialICE/simba/output.lua
index a01e074..10977ea 100644
--- a/SerialICE/simba/output.lua
+++ b/SerialICE/simba/output.lua
@@ -21,17 +21,17 @@ function printk(f, action, fmt, ...)
end
if action.to_hw then
str = str .. "H"
- elseif action.to_qemu then
- str = str .. "Q"
else
str = str .. "."
end
- if action.undefined then
- str = str .. "U"
+ if action.to_qemu then
+ str = str .. "Q"
else
str = str .. "."
end
- if action.dropped then
+ if action.undefined then
+ str = str .. "U"
+ elseif action.dropped then
str = str .. "D"
elseif action.faked then
str = str .. "F"
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2580
-gerrit
commit 25cea143bd7c0ea477f115e51dfa319dde02d40d
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Mar 4 10:17:37 2013 +0200
Do not add RAM filters on default_setup()
To forward JEDEC init cycles to dram memory banks, using the
memory fallback -filter, we must not enable RAM filters
already at start-up.
A mainboard-specific hook shall call enable_ram() only after
raminit and possible quick memtest have completed.
Change-Id: I9b3c0283fd4dd15b4d12e96e02e70d8ccc77f835
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/memory.lua | 49 ++++++++++++-------------------------------
SerialICE/simba/serialice.lua | 1 -
2 files changed, 13 insertions(+), 37 deletions(-)
diff --git a/SerialICE/simba/memory.lua b/SerialICE/simba/memory.lua
index 4e60bad..b05f09c 100644
--- a/SerialICE/simba/memory.lua
+++ b/SerialICE/simba/memory.lua
@@ -13,12 +13,7 @@ function mem_qemu_rom_pre(f, action)
end
function mem_rom_post(f, action)
- if not action.write then
- return true
- end
- -- Writes to ROM space fall-thru to the fallback filter,
- -- so they get logged there.
- return false
+ return true
end
filter_rom_low = {
@@ -81,21 +76,15 @@ end
ram_is_initialized = false
--- This is handled by SerialICE but *NOT* exclusively.
--- Writes end up in Qemu memory, too
-function mem_ram_low(f, action)
- if ram_is_initialized then
- -- RAM init is done. Send all RAM accesses
- -- to Qemu. Using the target as storage would
- -- only slow execution down.
- action.to_hw = false
- action.to_qemu = true
- else
- -- RAM init has not been marked done yet.
- -- so send reads to the target only.
- action.to_hw = true
- action.to_qemu = action.write
- end
+function mem_qemu_only(f, action)
+ action.to_hw = false
+ action.to_qemu = true
+ return true
+end
+
+function mem_target_only(f, action)
+ action.to_hw = true
+ action.to_qemu = false
return true
end
@@ -113,14 +102,10 @@ function mem_smi_vga(f, action)
end
-function mem_post_pre_ram_only(f, action)
- return ram_is_initialized
-end
-
filter_ram_low = {
name = "MEM",
pre = mem_ram_low,
- post = mem_post_pre_ram_only,
+ post = mem_post,
hide = true,
base = 0x0,
size = 0xa0000
@@ -138,19 +123,12 @@ filter_smi_vga = {
filter_ram_low_2 = {
name = "MEM",
pre = mem_ram_low,
- post = mem_post_pre_ram_only,
+ post = mem_post,
hide = true,
base = 0xc0000,
size = 0x20000
}
-
-function mem_target_only(f, action)
- action.to_hw = true
- action.to_qemu = false
- return true
-end
-
-- 3.25GB RAM. This is handled by SerialICE.
-- FIXME: use TOLM here
@@ -160,7 +138,7 @@ end
filter_ram_high = {
name = "MEM",
pre = mem_target_only,
- post = mem_post_pre_ram_only,
+ post = mem_post,
hide = true,
base = 0x100000,
size = 0xd0000000 - 0x100000
@@ -172,7 +150,6 @@ function ram_enabled()
end
function enable_ram()
-
enable_hook(mem_hooks, filter_ram_low)
enable_hook(mem_hooks, filter_smi_vga)
enable_hook(mem_hooks, filter_ram_low_2)
diff --git a/SerialICE/simba/serialice.lua b/SerialICE/simba/serialice.lua
index 82a2b03..7cabf67 100644
--- a/SerialICE/simba/serialice.lua
+++ b/SerialICE/simba/serialice.lua
@@ -78,7 +78,6 @@ function do_minimal_setup()
end
function do_default_setup()
- enable_ram()
enable_hook(mem_hooks, filter_lapic)
enable_hook(mem_hooks, filter_ioapic)
enable_hook(io_hooks, filter_pci_io_cfg)