target-arm: move arm_*_code to a separate file

These will soon require cpu_ldst.h, so move them out of cpu.h.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
softmmu: introduce cpu_ldst.h

This will collect all load and store helpers soon.  For now,
it is a replacement of softmmu_exec.h and we already include it
where it matters.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
softmmu: move all load/store functions to cpu_ldst.h

Unify pieces of cpu-all.h, exec-all.h, softmmu_exec.h and tcg/tcg.h
into a single new header file with all helpers.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386: rename KSMAP to KNOSMAP

This is the mode where SMAP is overridden, put "NO" in its name.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386: move check_io helpers to seg_helper.c

Prepare for adding _kernel accessors there in the next patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386: fix kernel accesses with SMAP and CPL = 3

With SMAP, implicit kernel accesses from user mode always behave as
if AC=0.  To do this, kernel mode is not anymore a separate MMU mode.
Instead, KERNEL_IDX is renamed to KSMAP_IDX and the kernel mode accessors
wrap KSMAP_IDX and KNOSMAP_IDX.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386: simplify SMAP handling in MMU_KSMAP_IDX

Do not use this MMU index at all if CR4.SMAP is false, and drop
the SMAP check from x86_cpu_handle_mmu_fault.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target-i386: fix checks on U/S bit for SMAP

The SDM says that supervisor-mode accesses are okay if at least one entry
in the page tables has the U/S bit set to zero.  Instead, the code is
marking accesses bad if at least one entry in the page tables has the
U/S bit set to one.  Correct this.

Cc: qemu-stable@nongnu.org
Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>