target-i386: introduce cpu_get_mem_attrs

Backports commit f794aa4a2fd772a3ec413c4e478cc23857cfee98 from qemu
This commit is contained in:
Paolo Bonzini 2018-02-13 11:33:35 -05:00 committed by Lioncash
parent 88d1506e6a
commit dc80b0893f
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 12 additions and 2 deletions

View 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;

View file

@ -1284,6 +1284,13 @@ static inline void cpu_load_efer(CPUX86State *env, uint64_t val)
}
}
static inline MemTxAttrs cpu_get_mem_attrs(CPUX86State *env)
{
MemTxAttrs attrs = {0};
attrs.secure = (env->hflags & HF_SMM_MASK) != 0;
return attrs;
}
/* fpu_helper.c */
void cpu_set_mxcsr(CPUX86State *env, uint32_t val);
void cpu_set_fpuc(CPUX86State *env, uint16_t val);

View file

@ -783,7 +783,8 @@ do_check_protect_pse36:
paddr = vaddr;
//printf(">>> map address %"PRIx64" to %"PRIx64"\n", vaddr, paddr);
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;