File tree Expand file tree Collapse file tree 5 files changed +18
-0
lines changed
Expand file tree Collapse file tree 5 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,12 @@ void Machine::run(float timeout)
286286 return vcpu.run (timeout * 1000.0 );
287287}
288288
289+ void Machine::run_in_usermode (float timeout)
290+ {
291+ this ->enter_usermode ();
292+ this ->run (timeout);
293+ }
294+
289295__attribute__ ((cold, noreturn))
290296void Machine::machine_exception (const char * msg, uint64_t data)
291297{
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ struct Machine
2828 void setup_linux (const std::vector<std::string>& args,
2929 const std::vector<std::string>& env = {});
3030 void run (float timeout_secs = 0 .f);
31+ void run_in_usermode (float timeout_secs = 0 .f);
3132
3233 /* Make a SYSV function call into the VM, with no timeout */
3334 template <typename ... Args>
@@ -108,6 +109,7 @@ struct Machine
108109 const tinykvm_x86regs& registers () const ;
109110 void set_registers (const tinykvm_x86regs&);
110111 tinykvm_fpuregs fpu_registers () const ;
112+ void set_fpu_registers (const tinykvm_fpuregs&);
111113 const kvm_sregs& get_special_registers () const ;
112114 void set_special_registers (const kvm_sregs&);
113115 std::pair<__u64, __u64> get_fsgs () const ;
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ inline void Machine::set_registers(const tinykvm_x86regs& regs) {
3636inline tinykvm_fpuregs Machine::fpu_registers () const {
3737 return vcpu.fpu_registers ();
3838}
39+ inline void Machine::set_fpu_registers (const tinykvm_fpuregs& regs) {
40+ vcpu.set_fpu_registers (regs);
41+ }
3942inline const struct kvm_sregs & Machine::get_special_registers () const {
4043 return vcpu.get_special_registers ();
4144}
Original file line number Diff line number Diff line change @@ -276,6 +276,12 @@ tinykvm_fpuregs vCPU::fpu_registers() const
276276 }
277277 return regs;
278278}
279+ void vCPU::set_fpu_registers (const struct tinykvm_fpuregs & regs)
280+ {
281+ if (ioctl (this ->fd , KVM_SET_FPU, ®s) < 0 ) {
282+ Machine::machine_exception (" KVM_SET_FPU failed" );
283+ }
284+ }
279285const kvm_sregs& vCPU::get_special_registers () const
280286{
281287#ifndef TINYKVM_USE_SYNCED_SREGS
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ namespace tinykvm
1515 const tinykvm_x86regs& registers () const ;
1616 void set_registers (const struct tinykvm_x86regs &);
1717 tinykvm_fpuregs fpu_registers () const ;
18+ void set_fpu_registers (const struct tinykvm_fpuregs &);
1819 const struct kvm_sregs & get_special_registers () const ;
1920 struct kvm_sregs & get_special_registers ();
2021 void set_special_registers (const struct kvm_sregs &);
You can’t perform that action at this time.
0 commit comments