Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bugfix I would like to contribute back #44

Open
syslaz opened this issue Apr 4, 2020 · 1 comment
Open

A bugfix I would like to contribute back #44

syslaz opened this issue Apr 4, 2020 · 1 comment

Comments

@syslaz
Copy link

syslaz commented Apr 4, 2020

@wbenny
Related to issue: #37

For some reason on 6th gen Intels and newer this does not cause any issue, however on older Intel CPUs it will cause system instability/freezing. The function below is responsible for the determining the memory cache type that each page on the EPT is configured to. The bug in the code lies in fact that the original code's default result is "memory_type::uncacheable" even though a valid mttr descriptor for that memory range was found.

I spent weeks looking into every line of hvpp until I finally stumbled upon this one bug that was fixed by adding just 3 lines.

In hvpp/lib/mttr_descriptor.h:

     memory_type type(pa_t pa) const noexcept
      {
        memory_type result = memory_type::invalid;

        for (auto mtrr_item : *this)
        {
          if (mtrr_item.range.contains(pa))
          {
            if (is_fixed(mtrr_item) || mtrr_item.type == memory_type::uncacheable)
            {
              result = mtrr_item.type;
              break;
            }

            if ( result == memory_type::write_back && (result == memory_type::write_through || mtrr_item.type == memory_type::write_through))
            {
              result = memory_type::write_through;
            } else
            {
                result = mtrr_item.type; // TODO bruhh
            }
          }
        }

        if (result == memory_type::invalid)
        {
          result = default_memory_type_;
        }

        return result;
      }

Other than that I've found that hvpp is a really well written hypervisor and has a lot of potential. Thanks!

@ghost
Copy link

ghost commented Mar 6, 2021

thanks, i also find this bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant