Code Monkey home page Code Monkey logo

bochscpu's Issues

Simulate CPU with UIMP feature

During fuzzing a kernel driver via WTF fuzzer with bochscpu backend for one case I got #GP (--> nt!KiGeneralProtectionFault() ) on the instruction:
fffff8062804a378 0f22e0 mov cr4,rax

Inside nt!KiFlushCurrentTbWorker():

image

I caught the reason in the debug build of bochs: check_CR4(): write of 0x00350e78 not supported (allowMask=0x3727ff)
(https://sourceforge.net/p/bochs/code/HEAD/tree/trunk/bochs/cpu/crregs.cc#l1273)

Decoded:
001101110010011111111111 - allowed mask
001101010000111001111000 - new value

11 bit is important for now:
// [11] UMIP: User Mode Instruction Prevention R/W
(https://sourceforge.net/p/bochs/code/HEAD/tree/trunk/bochs/cpu/crregs.cc#l1172)

And this bit isn't set:

  if (is_cpu_extension_supported(BX_ISA_UMIP))
    allowMask |= BX_CR4_UMIP_MASK;

(https://sourceforge.net/p/bochs/code/HEAD/tree/trunk/bochs/cpu/crregs.cc#l1251)

The flag BX_ISA_UMIP is set (enable_cpu_extension(BX_ISA_UMIP);) for 3 CPU profiles:

Inside this project the CPU profile selection is simulated in the sim_get_param_enum() function, which uses PARAMS_ENUM with "cpu.model" key:

bochscpu/src/sim.rs

Lines 20 to 54 in 20f197b

m.insert(
"cpu.model",
ParamEnum::new(
cstr!("model"),
&[
cstr!("bx_generic"),
cstr!("pentium"),
cstr!("pentium_mxx"),
cstr!("amd_k6_2_chomper"),
cstr!("p2_klamath"),
cstr!("p3_katmai"),
cstr!("p4_willamette"),
cstr!("core_duo_t2500_yonah"),
cstr!("atom_n270"),
cstr!("p4_prescott_celeron_336"),
cstr!("athlon64_clawhammer"),
cstr!("athlon64_venice"),
cstr!("turion64_tyler"),
cstr!("phenom_8650_toliman"),
cstr!("core2_penryn_t9600"),
cstr!("corei5_lynnfield_750"),
cstr!("corei5_arrandale_m520"),
cstr!("corei7_sandy_bridge_2600k"),
cstr!("zambezi"),
cstr!("trinity_apu"),
cstr!("ryzen"),
cstr!("corei7_ivy_bridge_3770k"),
cstr!("corei7_haswell_4770"),
cstr!("broadwell_ult"),
cstr!("corei7_skylake_x"),
cstr!("corei3_cnl"),
],
24
)
);

According to this part, the hardcoded value of 24 always means "corei7_skylake_x", which does not support UMIP.
I think it would be nice to sync with the actual cpudb.h and return the value 27 for the latest CPU profile (tigerlake):
https://sourceforge.net/p/bochs/code/HEAD/tree/trunk/bochs/cpudb.h#l55

unwind_attributes features has be removed

Hello,
I encountered this error with rust 1.54

error[E0557]: feature has been removed
 --> vendor\bochscpu\src\lib.rs:1:12
  |
1 | #![feature(unwind_attributes)]
  |            ^^^^^^^^^^^^^^^^^ feature has been removed
  |
  = note: use the C-unwind ABI instead

I guess it's related to rust-lang/rfcs#2945

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.