xen: Relocate mem_access and mem_event into common.

In preparation to add support for ARM LPAE mem_event, relocate mem_access,
mem_event and auxiliary functions into common Xen code.
This patch makes no functional changes to the X86 side, for ARM mem_event
and mem_access functions are just defined as placeholder stubs, and are
actually enabled later in the series.

Edits that are only header path adjustments:
   xen/arch/x86/domctl.c
   xen/arch/x86/mm/hap/nested_ept.c
   xen/arch/x86/mm/hap/nested_hap.c
   xen/arch/x86/mm/mem_paging.c
   xen/arch/x86/mm/mem_sharing.c
   xen/arch/x86/mm/p2m-pod.c
   xen/arch/x86/mm/p2m-pt.c
   xen/arch/x86/mm/p2m.c
   xen/arch/x86/x86_64/compat/mm.c
   xen/arch/x86/x86_64/mm.c

Makefile adjustments for new/removed code:
   xen/common/Makefile
   xen/arch/x86/mm/Makefile

Relocated prepare_ring_for_helper and destroy_ring_for_helper functions:
   xen/include/xen/mm.h
   xen/common/memory.c
   xen/include/asm-x86/hvm/hvm.h
   xen/arch/x86/hvm/hvm.c

Code movement of mem_event and mem_access with required ifdef wrappers
added to only compile with CONFIG_X86:
    xen/arch/x86/mm/mem_access.c -> xen/common/mem_access.c
    xen/arch/x86/mm/mem_event.c -> xen/common/mem_event.c
    xen/include/asm-x86/mem_access.h -> xen/include/xen/mem_access.h
    xen/include/asm-x86/mem_event.h -> xen/include/xen/mem_event.h

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
---
v2: Update MAINTAINERS.
    More descriptive commit message to aid in the review process.
xen/mem_event: Clean out superflous white-spaces

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
xen/mem_event: Relax error condition on debug builds

A faulty tool stack can brick a debug hypervisor. Unpleasant while dev/test.

Suggested-by: Andres Lagar Cavilla <andres@lagarcavilla.org>
Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
xen/mem_event: Abstract architecture specific sanity checks

Move architecture specific sanity checks into its own function
which is called when enabling mem_event.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
xen/mem_access: Abstract architecture specific sanity check

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
xen/arm: Enable the compilation of mem_access and mem_event on ARM.

This patch sets up the infrastructure to support mem_access and mem_event
 on ARM and turns on compilation. We define the required XSM functions,
handling of domctl copyback, and the required p2m types and stub-functions
in this patch.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
---
v2: Add CONFIG_MEM_PAGING and CONFIG_MEM_SHARING definitions and
       use them instead of CONFIG_X86.
    Also include several style fixes.
tools/libxc: Allocate magic page for mem access on ARM

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
xen/arm: Data abort exception (R/W) mem_events.

This patch replaces the stub p2m functions with the actual ones required to
store, set, check and deliver LPAE R/W mem_events. As the LPAE PTE lacks
available bits to store the p2m_access_t bits, we use a separate radix
tree (mem_access_settings) to store the permissions with the key being the
gfn.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
---
v2:
    Add definitions of data abort data fetch status codes (enum dabt_dfsc)
      and only call p2m_mem_access_check for traps caused by permission violations.

    Only call p2m_write_pte in p2m_lookup if the PTE permission actually changed.

    Properly save settings in the Radix tree and pause the VCPU with
      mem_event_vcpu_pause.
xen/arm: Instruction prefetch abort (X) mem_event handling

Add missing structure definition for iabt and update the trap handling
mechanism to only inject the exception if the mem_access checker
decides to do so.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
---
v2: Add definition for instruction abort instruction fetch status codes (enum iabt_ifsc)
       and only call p2m_mem_access_check for traps triggered for permission violations.
tools/tests: Enable xen-access on ARM

On ARM the guest memory doesn't start from 0, thus we include the
required headers and define GUEST_RAM_BASE_PFN in both architecture
to be passed to mem_access as the starting pfn.
We also define the ARM specific test_and_set_bit function.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>