mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 18:44:58 -06:00
cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook
Note that while such functions may exist both for *-user and softmmu, only *-user uses the CPUState hook, while softmmu reuses the prototype for calling it directly. Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
7372c2b926
commit
7510454e3e
61 changed files with 238 additions and 151 deletions
|
@ -2810,7 +2810,9 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
|
|||
cc->gdb_write_register = x86_cpu_gdb_write_register;
|
||||
cc->get_arch_id = x86_cpu_get_arch_id;
|
||||
cc->get_paging_enabled = x86_cpu_get_paging_enabled;
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
cc->handle_mmu_fault = x86_cpu_handle_mmu_fault;
|
||||
#else
|
||||
cc->get_memory_mapping = x86_cpu_get_memory_mapping;
|
||||
cc->get_phys_page_debug = x86_cpu_get_phys_page_debug;
|
||||
cc->write_elf64_note = x86_cpu_write_elf64_note;
|
||||
|
|
|
@ -1067,9 +1067,8 @@ void host_cpuid(uint32_t function, uint32_t count,
|
|||
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
|
||||
|
||||
/* helper.c */
|
||||
int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
|
||||
int x86_cpu_handle_mmu_fault(CPUState *cpu, vaddr addr,
|
||||
int is_write, int mmu_idx);
|
||||
#define cpu_handle_mmu_fault cpu_x86_handle_mmu_fault
|
||||
void x86_cpu_set_a20(X86CPU *cpu, int a20_state);
|
||||
|
||||
static inline bool hw_local_breakpoint_enabled(unsigned long dr7, int index)
|
||||
|
|
|
@ -485,9 +485,12 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4)
|
|||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
|
||||
int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
|
||||
int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr,
|
||||
int is_write, int mmu_idx)
|
||||
{
|
||||
X86CPU *cpu = X86_CPU(cs);
|
||||
CPUX86State *env = &cpu->env;
|
||||
|
||||
/* user mode only emulation */
|
||||
is_write &= 1;
|
||||
env->cr[2] = addr;
|
||||
|
@ -508,14 +511,15 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
|
|||
# endif
|
||||
|
||||
/* return value:
|
||||
-1 = cannot handle fault
|
||||
0 = nothing more to do
|
||||
1 = generate PF fault
|
||||
*/
|
||||
int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
|
||||
* -1 = cannot handle fault
|
||||
* 0 = nothing more to do
|
||||
* 1 = generate PF fault
|
||||
*/
|
||||
int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr,
|
||||
int is_write1, int mmu_idx)
|
||||
{
|
||||
CPUState *cs = CPU(x86_env_get_cpu(env));
|
||||
X86CPU *cpu = X86_CPU(cs);
|
||||
CPUX86State *env = &cpu->env;
|
||||
uint64_t ptep, pte;
|
||||
target_ulong pde_addr, pte_addr;
|
||||
int error_code, is_dirty, prot, page_size, is_write, is_user;
|
||||
|
@ -525,7 +529,7 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
|
|||
|
||||
is_user = mmu_idx == MMU_USER_IDX;
|
||||
#if defined(DEBUG_MMU)
|
||||
printf("MMU fault: addr=" TARGET_FMT_lx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
|
||||
printf("MMU fault: addr=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
|
||||
addr, is_write1, is_user, env->eip);
|
||||
#endif
|
||||
is_write = is_write1 & 1;
|
||||
|
|
|
@ -135,9 +135,10 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v)
|
|||
void tlb_fill(CPUX86State *env, target_ulong addr, int is_write, int mmu_idx,
|
||||
uintptr_t retaddr)
|
||||
{
|
||||
X86CPU *cpu = x86_env_get_cpu(env);
|
||||
int ret;
|
||||
|
||||
ret = cpu_x86_handle_mmu_fault(env, addr, is_write, mmu_idx);
|
||||
ret = x86_cpu_handle_mmu_fault(CPU(cpu), addr, is_write, mmu_idx);
|
||||
if (ret) {
|
||||
if (retaddr) {
|
||||
/* now we have a real cpu fault */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue