Home | History | Annotate | Download | only in hw
      1 /* Copyright (C) 2007-2008 The Android Open Source Project
      2 **
      3 ** This software is licensed under the terms of the GNU General Public
      4 ** License version 2, as published by the Free Software Foundation, and
      5 ** may be copied, distributed, and modified under those terms.
      6 **
      7 ** This program is distributed in the hope that it will be useful,
      8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
      9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10 ** GNU General Public License for more details.
     11 */
     12 #include "hw.h"
     13 #include "goldfish_vmem.h"
     14 #ifdef TARGET_I386
     15 #include "kvm.h"
     16 #endif
     17 
     18 
     19 // Both safe_memory_rw_debug and safe_get_phys_page_debug need to translate
     20 // virtual addresses to physical addresses. When running on KVM we need to
     21 // pull the cr registers and hflags from the VCPU. These functions wrap the
     22 // calls to kvm_get_sregs to pull these registers over when necessary.
     23 //
     24 // Note: we do not call the cpu_synchronize_state function because that pulls
     25 // all the VCPU registers. That equates to 4 ioctls on the KVM virtual device
     26 // and on AMD some of those ioctls (in particular KVM_GET_MSRS) are 10 to 100x
     27 // slower than on Intel chips.
     28 
     29 int safe_memory_rw_debug(CPUState *env, target_ulong addr, uint8_t *buf,
     30                          int len, int is_write)
     31 {
     32 #ifdef TARGET_I386
     33     if (kvm_enabled()) {
     34         kvm_get_sregs(env);
     35     }
     36 #endif
     37     return cpu_memory_rw_debug(env, addr, buf, len, is_write);
     38 }
     39 
     40 target_phys_addr_t safe_get_phys_page_debug(CPUState *env, target_ulong addr)
     41 {
     42 #ifdef TARGET_I386
     43     if (kvm_enabled()) {
     44         kvm_get_sregs(env);
     45     }
     46 #endif
     47     return cpu_get_phys_page_debug(env, addr);
     48 }
     49 
     50