Skip to content

Commit

Permalink
fixup: "hw: generic interface for x86 virtualization"
Browse files Browse the repository at this point in the history
Rename "get_exitcode()" to "handle_vm_exit()" and add arguments needed
for exit handling in VMX.

Issue genodelabs#5113
  • Loading branch information
atopia committed Feb 28, 2024
1 parent 2598f11 commit 140be67
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ void Vmcb::read_vcpu_state(Vcpu_state &state)
/* TPR threshold not used on AMD */
}

uint64_t Vmcb::get_exitcode()

uint64_t Vmcb::handle_vm_exit(unsigned &, bool)
{
enum Svm_exitcodes : uint64_t
{
Expand All @@ -447,10 +448,12 @@ uint64_t Vmcb::get_exitcode()
switch (exitcode) {
case VMEXIT_INVALID:
error("Vm::exception: invalid SVM state!");
// FIXME panic
break;
case 0x40 ... 0x5f:
error("Vm::exception: unhandled SVM exception ",
Hex(exitcode));
// FIXME panic
break;
case VMEXIT_INTR:
exitcode = EXIT_PAUSED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* under the terms of the GNU Affero General Public License version 3.
*/

#include "base/fixed_stdint.h"
#include <base/log.h>
#include <cpu/vcpu_state_virtualization.h>
#include <util/construct_at.h>
Expand Down Expand Up @@ -117,7 +118,9 @@ void Vm::exception(Cpu & cpu)
return;
}

_vcpu_context.exitcode = _vcpu_context.virt.get_exitcode();
unsigned irq { };
bool error { false };
_vcpu_context.exitcode = _vcpu_context.virt.handle_vm_exit(irq, error);

if (_vcpu_context.exitcode != EXIT_PAUSED) {
_pause_vcpu();
Expand Down
2 changes: 1 addition & 1 deletion repos/base-hw/src/core/spec/x86_64/virtualization/svm.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ struct Board::Vmcb
void write_vcpu_state(Vcpu_state &state) override;
void read_vcpu_state(Vcpu_state &state) override;
void switch_world(Core::Cpu::Context &regs) override;
uint64_t get_exitcode() override;
uint64_t handle_vm_exit(unsigned &irq, bool error = false) override;

Virt_type virt_type() override
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ struct Virt_interface

virtual void initialize(Kernel::Cpu &cpu,
Genode::addr_t page_table_phys_addr,
Core::Cpu::Context &regs) = 0;
virtual void write_vcpu_state(Genode::Vcpu_state &state) = 0;
virtual void read_vcpu_state(Genode::Vcpu_state &state) = 0;
virtual void switch_world(Core::Cpu::Context &regs) = 0;
virtual Genode::uint64_t get_exitcode() = 0;
virtual Virt_type virt_type() = 0;

Core::Cpu::Context &regs) = 0;
virtual void write_vcpu_state(Genode::Vcpu_state &state) = 0;
virtual void read_vcpu_state(Genode::Vcpu_state &state) = 0;
virtual void switch_world(Core::Cpu::Context &regs) = 0;
virtual Virt_type virt_type() = 0;
virtual Genode::uint64_t handle_vm_exit(unsigned &irq,
bool error = false) = 0;

Virt_interface(Genode::Vcpu_data &vcpu_data) : vcpu_data(vcpu_data)
{ }
Expand Down

0 comments on commit 140be67

Please sign in to comment.