Skip to content

Conversation

@marpom
Copy link
Contributor

@marpom marpom commented Mar 27, 2025

  • Fixes a bug when setting up a 64-bit guest by making the bit manipulation macros produce unsigned long long: To create a VCPU that has paging enabled, one needs to set the CR0.PE and CR0.PG bits in CR0. The latter is problematic when setting up a 64-bit guest since if the macro is not using 1ULL, it sign extends the output (in 64-bit mode the control registers are extended to 64-bits with some of the CR0[32:63] bits reserved). This results in either failing the KVM_SET_SREGS ioctl (in newer kernel versions) or just failing the KVM_RUN ioctl with EXIT_REASON_INVALID_STATE.

  • Moved some macro definitions to the generic kvm header to consolidate them with the already existing ones. Prefixed them with X86_ to avoid confusion. These will then be used by the x86-64 version of SYZOS.


Before sending a pull request, please review Contribution Guidelines:
https://github.com/google/syzkaller/blob/master/docs/contributing.md


@marpom marpom changed the title Bug fix and minor refactor in x86-64 KVM fuzzer executor/kvm :Bug fix and minor refactor in KVM Mar 27, 2025
@ramosian-glider
Copy link
Member

Please fix the title to be "executor/kvm: bug fix and minor refactor in KVM"

Copy link
Member

@ramosian-glider ramosian-glider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@marpom marpom changed the title executor/kvm :Bug fix and minor refactor in KVM executor/kvm: bug fix and minor refactor in KVM Mar 27, 2025
* Fixes a bug when setting up a 64-bit guest by making the bit
  manipulation macros produce unsigned long long: To create a VCPU that
  has paging enabled, one needs to set the CR0.PE and CR0.PG bits in
  CR0. The latter is problematic when setting up a 64-bit guest since if
  the macro is not using 1ULL, it sign extends the output (in 64-bit
  mode the control registers are extended to 64-bits with some of the
  CR0[32:63] bits reserved). This results in either failing the
  KVM_SET_SREGS ioctl (in newer kernel versions) or just failing the
  KVM_RUN ioctl with EXIT_REASON_INVALID_STATE.

* Moved the bit manipulation definitions from the amd64 specific to the generic
  kvm header to consolidate them with the already existing ones.
  Prefixed them with X86_ to avoid confusion.
@ramosian-glider ramosian-glider added this pull request to the merge queue Mar 27, 2025
Merged via the queue into google:master with commit 6c09fb8 Mar 27, 2025
17 checks passed
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

Successfully merging this pull request may close these issues.

2 participants