target-i386: introduce cpu_get_mem_attrs
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Apr 2015 12:52:04 +0000 (14:52 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 5 Jun 2015 15:10:00 +0000 (17:10 +0200)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/exec/memattrs.h
target-i386/cpu.h
target-i386/helper.c
target-i386/kvm.c

index 96dc44042305333f83672244329c0c0002d68582..f8537a8d9192ab4f2914cfc2e1e13de2c64502b6 100644 (file)
@@ -29,7 +29,9 @@ typedef struct MemTxAttrs {
      * "didn't specify" if necessary.
      */
     unsigned int unspecified:1;
-    /* ARM/AMBA TrustZone Secure access */
+    /* ARM/AMBA: TrustZone Secure access
+     * x86: System Management Mode access
+     */
     unsigned int secure:1;
     /* Memory access is usermode (unprivileged) */
     unsigned int user:1;
index 26182bdc7e69bfa0226a43b5f60e724b6a86f696..74e8819dba7a64592299b10c60ca9230a8afd489 100644 (file)
@@ -1292,6 +1292,11 @@ static inline void cpu_load_efer(CPUX86State *env, uint64_t val)
     }
 }
 
+static inline MemTxAttrs cpu_get_mem_attrs(CPUX86State *env)
+{
+    return ((MemTxAttrs) { .secure = (env->hflags & HF_SMM_MASK) != 0 });
+}
+
 /* fpu_helper.c */
 void cpu_set_mxcsr(CPUX86State *env, uint32_t val);
 void cpu_set_fpuc(CPUX86State *env, uint16_t val);
index 4f1ddf701e5e661bbf5e112aae0e1c5e9aac9a8b..62e801b28efc118d3a0f5f7064a641d0aa273cc3 100644 (file)
@@ -771,7 +771,8 @@ do_check_protect_pse36:
     page_offset = vaddr & (page_size - 1);
     paddr = pte + page_offset;
 
-    tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size);
+    tlb_set_page_with_attrs(cs, vaddr, paddr, cpu_get_mem_attrs(env),
+                            prot, mmu_idx, page_size);
     return 0;
  do_fault_rsvd:
     error_code |= PG_ERROR_RSVD_MASK;
index ca2da84501b05d541ef1e039a728488155127bf3..5a236e3103acd2e45e4bb452a4c552c1c1daa23f 100644 (file)
@@ -2259,7 +2259,7 @@ MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
     }
     cpu_set_apic_tpr(x86_cpu->apic_state, run->cr8);
     cpu_set_apic_base(x86_cpu->apic_state, run->apic_base);
-    return MEMTXATTRS_UNSPECIFIED;
+    return cpu_get_mem_attrs(env);
 }
 
 int kvm_arch_process_async_events(CPUState *cs)