RVM-Tutorial icon indicating copy to clipboard operation
RVM-Tutorial copied to clipboard

cr_is_valid是否存在问题?

Open asueeer opened this issue 2 years ago • 1 comments

// Check control registers are in a VMX-friendly state. (SDM Vol. 3C, Appendix A.7, A.8) /
        macro_rules! cr_is_valid {
            ($value: expr, $crx: ident) => {{
                use Msr::*;
                let value = $value;
                let fixed0 = concat_idents!(IA32_VMX_, $crx, _FIXED0).read();
                let fixed1 = concat_idents!(IA32_VMX_, $crx, _FIXED1).read();
                (!fixed0 | value != 0) && (fixed1 | !value != 0)
            }};
        }

函数最终返回 (!fixed0 | value != 0) && (fixed1 | !value != 0), 但是根据手册,FIXED0应该是所在位为1的,寄存器所在位也为1; FIXED1应该是所在位为0的,寄存器所在位也为0, 判断结果应该写为(value & fixed0 == fixed0) && (value & !fixed1 == 0)才对吧。 不过这样就无法通过检查了。 我看其他开源项目是,先有一个调整寄存器值的操作。

asueeer avatar Jul 22 '23 15:07 asueeer

You are right, fixed by the following expression in 907afda:

(!fixed0 | value == !0) && (fixed1 | !value == !0)

equation314 avatar Sep 10 '23 13:09 equation314