Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15062
-gerrit
commit 7f60cfda0173c1c87ae54933a2d40b8d5060d0c4 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Fri Jun 3 18:30:08 2016 +0300
Cleanup on filter return values
Rewrite to make it clear what value hooks return. In all simplicity, return true if the instruction is processed by the filter and return false otherwise.
On pre-hooks, returning true indicates further pre-hooks will not be processed.
Change-Id: I201de34727cf5f0a3dfc6d869317c9cbe2ae41c7 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- SerialICE/simba/chipset/intel_smbus.lua | 3 +- SerialICE/simba/chipset/pc80.lua | 54 +++++++++++++++--------- SerialICE/simba/chipset/superio.lua | 23 ++++++---- SerialICE/simba/cpu.lua | 36 ++++++++++------ SerialICE/simba/hooks.lua | 12 +----- SerialICE/simba/mainboard/aopen_dxpl_plus.lua | 22 ++++++---- SerialICE/simba/mainboard/asus_p4p800_vm.lua | 22 ++++++---- SerialICE/simba/mainboard/commell_lv_672.lua | 10 +++-- SerialICE/simba/mainboard/conroexfire_esata2.lua | 22 ++++++---- SerialICE/simba/mainboard/intel_d845gbv2.lua | 16 ++++--- SerialICE/simba/mainboard/intel_d946gzis.lua | 16 ++++--- SerialICE/simba/mainboard/lenovo_x61.lua | 3 +- SerialICE/simba/mainboard/msi_ms7133.lua | 16 ++++--- SerialICE/simba/mainboard/via_epia_m_850.lua | 22 ++++++---- SerialICE/simba/mmio.lua | 6 ++- SerialICE/simba/pci_cfg.lua | 11 +++-- 16 files changed, 180 insertions(+), 114 deletions(-)
diff --git a/SerialICE/simba/chipset/intel_smbus.lua b/SerialICE/simba/chipset/intel_smbus.lua index c2156f8..6c023da 100644 --- a/SerialICE/simba/chipset/intel_smbus.lua +++ b/SerialICE/simba/chipset/intel_smbus.lua @@ -224,7 +224,8 @@ function intel_smbus_host_pre(f, action) if action.write then intel_smbus_host_access(f, action) end - return handle_action(f, action) + handle_action(f, action) + return true end
function intel_smbus_host_post(f, action) diff --git a/SerialICE/simba/chipset/pc80.lua b/SerialICE/simba/chipset/pc80.lua index a1e3fdc..3d7c15a 100644 --- a/SerialICE/simba/chipset/pc80.lua +++ b/SerialICE/simba/chipset/pc80.lua @@ -29,9 +29,10 @@ function i8259_pre(f, action) local slave = ((0x05 >> action.addr) == 0x5) local reg = (0x03 & action.addr) if reg == 0 or reg == 1 then - return handle_action(f, action) + handle_action(f, action) + return true end - return skip_filter(f, action) + return false end
function i8259_post(f,action) @@ -43,7 +44,8 @@ function i8259_post(f,action) end
function i8259_edge_pre(f, action) - return handle_action(f, action) + handle_action(f, action) + return true end
function i8259_edge_post(f,action) @@ -83,9 +85,10 @@ filter_i8259_edge = {
function i8237_pre(f, action) if action.addr == 0x80 then - return skip_filter(f, action) + return false end - return handle_action(f, action) + handle_action(f, action) + return true end
function i8237_post(f, action) @@ -130,7 +133,8 @@ function i8254_pre(f, action)
-- nothing to do on reads if not action.write then - return handle_action(f, action) + handle_action(f, action) + return true end
local reg = (0x03 & action.addr) @@ -176,7 +180,8 @@ function i8254_pre(f, action) end end end - return handle_action(f, action) + handle_action(f, action) + return true end
function i8254_post(f, action) @@ -266,25 +271,29 @@ function i8042_write(f, action) if (f.reg.cmd == 0xd1) then f.reg.A20 = ((0x02 & action.data) == 0x02) end - return handle_action(f, action) + handle_action(f, action) + return true end if action.addr == 0x64 then f.reg.cmd = action.data f.reg.sts = (f.reg.sts | 0x0a) - return handle_action(f, action) + handle_action(f, action) + return true end - return skip_filter(f, action) + return false end
function i8042_read(f, action) if action.addr == 0x60 then f.reg.sts = (f.reg.sts & 0xfe) - return handle_action(f, action) + handle_action(f, action) + return true end if action.addr == 0x64 then - return handle_action(f, action) + handle_action(f, action) + return true end - return skip_filter(f, action) + return false end
function i8042_pre(f, action) @@ -370,9 +379,11 @@ function nvram_write(f, action) end end if cache_nvram and not rtc then - return fake_action(f, action, val) + fake_action(f, action, val) + return true else - return handle_action(f, action) + handle_action(f, action) + return true end end
@@ -408,9 +419,11 @@ function nvram_read(f, action) end end if cache_nvram and not rtc then - return fake_action(f, action, val) + fake_action(f, action, val) + return true else - return handle_action(f, action) + handle_action(f, action) + return true end end
@@ -466,9 +479,10 @@ function sys_rst_pre(f, action) if action.write and (action.data & 0x04) == 0x04 then SerialICE_system_reset() end - return handle_action(f, action) + handle_action(f, action) + return true end - return skip_filter(f, action) + return false end
function sys_rst_post(f, action) @@ -495,7 +509,7 @@ filter_reset = { -- VGA io
function vga_io_pre(f, action) - return skip_filter(f, action) + return false end
function vga_io_post(f, action) diff --git a/SerialICE/simba/chipset/superio.lua b/SerialICE/simba/chipset/superio.lua index 03e1e61..2607b5b 100644 --- a/SerialICE/simba/chipset/superio.lua +++ b/SerialICE/simba/chipset/superio.lua @@ -101,12 +101,14 @@ end
function superio_pre(f, action) if not action.write then - return handle_action(f, action) + handle_action(f, action) + return true end
if action.addr == f.base then pnp_select_cfg(f, action.data) - return handle_action(f, action) + handle_action(f, action) + return true end
if action.addr == f.base + 0x01 then @@ -119,18 +121,21 @@ function superio_pre(f, action)
-- Don't allow that our SIO power gets disabled. if f.pnp.reg == 0x02 then - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
-- Don't mess with oscillator setup. if f.pnp.reg == 0x24 then - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end - return handle_action(f, action) + handle_action(f, action) + return true end
-- should not reach here - return skip_filter(f, action) + return false end
function superio_post(f, action) @@ -246,9 +251,11 @@ end
function com_pre(f, action) if (action.write) then - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true else - return drop_action(f, action, 0xff) + drop_action(f, action, 0xff) + return true end end
diff --git a/SerialICE/simba/cpu.lua b/SerialICE/simba/cpu.lua index 10a7fe4..86ec758 100644 --- a/SerialICE/simba/cpu.lua +++ b/SerialICE/simba/cpu.lua @@ -34,7 +34,8 @@ end function mtrr_pre(f, action) local addr = action.rin.ecx if addr >= 0x200 and addr < 0x210 then - return handle_action(f, action) + handle_action(f, action) + return true end return false end @@ -55,7 +56,8 @@ filter_mtrr = { }
function cpumsr_pre(f, action) - return handle_action(f, action) + handle_action(f, action) + return true end
function cpumsr_post(f, action) @@ -85,7 +87,8 @@ microcode_patchlevel_eax = 0 microcode_patchlevel_edx = 0
function cpuid_pre(f, action) - return handle_action(f, action) + handle_action(f, action) + return true end
function cpuid_post(f, action) @@ -105,7 +108,7 @@ filter_cpuid_fallback = {
function multicore_pre(f, action) - return skip_filter(f, action) + return false end
function multicore_post(f, action) @@ -116,9 +119,10 @@ function multicore_post(f, action) if not action.write and rin.eax == 0x01 then rout.ebx = (0xff00ffff & rout.ebx); rout.ebx = (0x00010000 | rout.ebx); - return fake_action(f, action, 0) + fake_action(f, action, 0) + return true end - return skip_filter(f, action) + return false end
filter_multiprocessor = { @@ -133,9 +137,10 @@ function intel_microcode_pre(f, action) --action.dropped = true --action.rout.edx = 0 --action.rout.eax = 0xffff0000 - return drop_action(f, action) + drop_action(f, action) + return true end - return skip_filter(f, action) + return false end
-- Intel CPU microcode revision check @@ -144,9 +149,10 @@ function intel_microcode_post(f, action) if action.rin.ecx == 0x8b then action.rout.edx = microcode_patchlevel_edx action.rout.eax = microcode_patchlevel_eax - return fake_action(f, action, 0) + fake_action(f, action, 0) + return true end - return skip_filter(f, action) + return false end
filter_intel_microcode = { @@ -161,9 +167,10 @@ function amd_microcode_pre(f, action) --action.dropped = true --action.rout.edx = 0 --action.rout.eax = 0xffff0000 - return drop_action(f, action) + drop_action(f, action) + return true end - return skip_filter(f, action) + return false end
-- AMD CPU microcode revision check @@ -172,9 +179,10 @@ function amd_microcode_post(f, action) if action.rin.ecx == 0x8b then action.rout.eax = microcode_patchlevel_eax action.rout.edx = microcode_patchlevel_edx - return fake_action(f, action, 0) + fake_action(f, action, 0) + return true end - return skip_filter(f, action) + return false end
filter_amd_microcode = { diff --git a/SerialICE/simba/hooks.lua b/SerialICE/simba/hooks.lua index 2ce5f36..0a3c38b 100644 --- a/SerialICE/simba/hooks.lua +++ b/SerialICE/simba/hooks.lua @@ -171,17 +171,15 @@ POST_HOOK = 2
function handle_action(f, action) action.to_hw = true - return true end
function drop_action(f, action, data) if action.stage == POST_HOOK then printk(f, action, "ERROR: Cannot drop action in a post-hook.\n") - return true + return end action.dropped = true action.data = data - return true end
function ignore_action(f, action) @@ -191,16 +189,10 @@ end function fake_action(f, action, data) if action.stage == POST_HOOK and action.write then printk(f, action, "ERROR: Cannot fake write in a post-hook.\n") - return true + return end action.faked = true action.data = data - return true -end - - -function skip_filter(f, action) - return false end
function pre_action(action, dir_wr, addr, size, data) diff --git a/SerialICE/simba/mainboard/aopen_dxpl_plus.lua b/SerialICE/simba/mainboard/aopen_dxpl_plus.lua index 1a4c715..ffd21ef 100644 --- a/SerialICE/simba/mainboard/aopen_dxpl_plus.lua +++ b/SerialICE/simba/mainboard/aopen_dxpl_plus.lua @@ -32,26 +32,30 @@ function mainboard_io_read(f, action) if ( action.addr == 0x61 ) then if ( regs.eip == 0x1634 ) then regs.ecx = 0x01 - return fake_action(f, action, 0x20) + fake_action(f, action, 0x20) + return true end if ( regs.eip == 0x163a ) then regs.ecx = 0x01 - return fake_action(f, action, 0x30) + fake_action(f, action, 0x30) + return true end end
-- IO slowdown if action.addr == 0xed then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
@@ -64,7 +68,8 @@ function mainboard_io_write(f, action)
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xed then @@ -81,10 +86,11 @@ if false then end end ignore_action(f, action) - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_pre(f, action) diff --git a/SerialICE/simba/mainboard/asus_p4p800_vm.lua b/SerialICE/simba/mainboard/asus_p4p800_vm.lua index 88c4002..ab90679 100644 --- a/SerialICE/simba/mainboard/asus_p4p800_vm.lua +++ b/SerialICE/simba/mainboard/asus_p4p800_vm.lua @@ -5,26 +5,30 @@ function mainboard_io_read(f, action) if ( action.addr == 0x61 ) then if ( regs.eip == 0x1634 ) then regs.ecx = 0x01 - return fake_action(f, action, 0x20) + fake_action(f, action, 0x20) + return true end if ( regs.eip == 0x163a ) then regs.ecx = 0x01 - return fake_action(f, action, 0x30) + fake_action(f, action, 0x30) + return true end end
-- IO slowdown if action.addr == 0xed then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
@@ -33,15 +37,17 @@ function mainboard_io_write(f, action)
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xe1 then ignore_action(f, action) - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_pre(f, action) diff --git a/SerialICE/simba/mainboard/commell_lv_672.lua b/SerialICE/simba/mainboard/commell_lv_672.lua index 85e4421..1074c9d 100644 --- a/SerialICE/simba/mainboard/commell_lv_672.lua +++ b/SerialICE/simba/mainboard/commell_lv_672.lua @@ -3,10 +3,11 @@ function mainboard_io_read(f, action) -- IO slowdown if action.addr == 0xeb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
@@ -14,10 +15,11 @@ function mainboard_io_write(f, action) -- IO slowdown if action.addr == 0xeb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_pre(f, action) diff --git a/SerialICE/simba/mainboard/conroexfire_esata2.lua b/SerialICE/simba/mainboard/conroexfire_esata2.lua index 4c95e6d..5402910 100644 --- a/SerialICE/simba/mainboard/conroexfire_esata2.lua +++ b/SerialICE/simba/mainboard/conroexfire_esata2.lua @@ -6,26 +6,30 @@ function mainboard_io_read(f, action) if ( action.addr == 0x61 ) then if ( regs.eip == 0x1634 ) then regs.ecx = 0x01 - return fake_action(f, action, 0x20) + fake_action(f, action, 0x20) + return true end if ( regs.eip == 0x163a ) then regs.ecx = 0x01 - return fake_action(f, action, 0x30) + fake_action(f, action, 0x30) + return true end end
-- IO slowdown if action.addr == 0xed then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
@@ -34,15 +38,17 @@ function mainboard_io_write(f, action)
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xe1 then ignore_action(f, action) - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_pre(f, action) diff --git a/SerialICE/simba/mainboard/intel_d845gbv2.lua b/SerialICE/simba/mainboard/intel_d845gbv2.lua index 0224356..cf22a63 100644 --- a/SerialICE/simba/mainboard/intel_d845gbv2.lua +++ b/SerialICE/simba/mainboard/intel_d845gbv2.lua @@ -8,15 +8,17 @@ function mainboard_io_read(f, action) -- IO slowdown if action.addr == 0xed then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
@@ -29,15 +31,17 @@ function mainboard_io_write(f, action)
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xe1 then ignore_action(f, action) - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_pre(f, action) diff --git a/SerialICE/simba/mainboard/intel_d946gzis.lua b/SerialICE/simba/mainboard/intel_d946gzis.lua index d1c92b1..56bf279 100644 --- a/SerialICE/simba/mainboard/intel_d946gzis.lua +++ b/SerialICE/simba/mainboard/intel_d946gzis.lua @@ -5,15 +5,17 @@ function mainboard_io_read(f, action) -- IO slowdown if action.addr == 0xed then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
@@ -22,15 +24,17 @@ function mainboard_io_write(f, action)
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xe1 then ignore_action(f, action) - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_pre(f, action) diff --git a/SerialICE/simba/mainboard/lenovo_x61.lua b/SerialICE/simba/mainboard/lenovo_x61.lua index 2d59b1c..3d5c771 100644 --- a/SerialICE/simba/mainboard/lenovo_x61.lua +++ b/SerialICE/simba/mainboard/lenovo_x61.lua @@ -7,7 +7,8 @@ function mainboard_io_pre(f, action) -- disconnecting the dock we're connecting through if action.write and action.addr == 0x1680 then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end end
diff --git a/SerialICE/simba/mainboard/msi_ms7133.lua b/SerialICE/simba/mainboard/msi_ms7133.lua index 2aec108..b31c695 100644 --- a/SerialICE/simba/mainboard/msi_ms7133.lua +++ b/SerialICE/simba/mainboard/msi_ms7133.lua @@ -3,30 +3,34 @@ function mainboard_io_read(f, action) -- IO slowdown if action.addr == 0xed then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_write(f, action) if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xe1 then ignore_action(f, action) - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_pre(f, action) diff --git a/SerialICE/simba/mainboard/via_epia_m_850.lua b/SerialICE/simba/mainboard/via_epia_m_850.lua index 4f5dc14..7aa257d 100644 --- a/SerialICE/simba/mainboard/via_epia_m_850.lua +++ b/SerialICE/simba/mainboard/via_epia_m_850.lua @@ -31,21 +31,24 @@ function mainboard_io_read(f, action) -- IO slowdown if action.addr == 0xed then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
-- IO slowdown if action.addr == 0xeb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
if action.addr == 0xcfb then ignore_action(f, action) - return drop_action(f, action, 0) + drop_action(f, action, 0) + return true end
- return skip_filter(f, action) + return false end
@@ -58,20 +61,23 @@ function mainboard_io_write(f, action)
-- if action.addr == 0xcfb then -- ignore_action(f, action) --- return drop_action(f, action, 0) +-- drop_action(f, action, 0) + return true -- end
if action.addr == 0xeb then ignore_action(f, action) - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true end
if action.addr == 0xed then ignore_action(f, action) - return drop_action(f, action, action.data) + drop_action(f, action, action.data) + return true end
- return skip_filter(f, action) + return false end
function mainboard_io_pre(f, action) diff --git a/SerialICE/simba/mmio.lua b/SerialICE/simba/mmio.lua index 628a87e..e642de7 100644 --- a/SerialICE/simba/mmio.lua +++ b/SerialICE/simba/mmio.lua @@ -10,10 +10,12 @@ function mem_lapic(f, action) if (action.addr & f.size-1) == 0x300 then -- replace Start-Up IPI with Init IPI if action.write and (action.data & 0xf0f00) == 0xc0600 then - return fake_action(f, action, 0xc0500) + fake_action(f, action, 0xc0500) + return true end end - return handle_action(f, action) + handle_action(f, action) + return true end
filter_lapic = { diff --git a/SerialICE/simba/pci_cfg.lua b/SerialICE/simba/pci_cfg.lua index e0f7784..6fbd41b 100644 --- a/SerialICE/simba/pci_cfg.lua +++ b/SerialICE/simba/pci_cfg.lua @@ -249,13 +249,15 @@ function pci_io_cfg_pre(f, action) bdfr = bdfr | (action.data & 0xfc) pci_cfg_select(f, bdfr) end - return handle_action(f, action) + handle_action(f, action) + return true end if action.addr >= 0xcfc and action.addr <= 0xcff then pci_cfg_access(f, action) - return handle_action(f, action) + handle_action(f, action) + return true end - return skip_filter(f, action) + return false end
function pci_io_cfg_post(f, action) @@ -293,7 +295,8 @@ function pci_mm_cfg_pre(f, action) pci_cfg_select(f, bdfr) pci_cfg_access(f, action)
- return handle_action(f, action) + handle_action(f, action) + return true end
function pci_mm_cfg_post(f, action)