[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC 2/3] s390x/tcg: low-address protection suppo
From: |
Thomas Huth |
Subject: |
Re: [Qemu-devel] [PATCH RFC 2/3] s390x/tcg: low-address protection support |
Date: |
Thu, 28 Sep 2017 06:50:39 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 27.09.2017 19:00, David Hildenbrand wrote:
> This is a neat way to implement low address protection, whereby
> only the first 512 bytes of the first two pages (each 4096 bytes) of
> every address space are protected.
>
> Store a tec of 0 for the access exception, this is what is defined by
> Enhanced Suppression on Protection in case of a low address protection
> (Bit 61 set to 0, rest undefined).
>
> We have to make sure to to pass the access address, not the masked page
> address into mmu_translate*().
>
> Drop the check from testblock. So we can properly test this via
> kvm-unit-tests.
>
> This will check every access going through one of the MMUs.
>
> Signed-off-by: David Hildenbrand <address@hidden>
> ---
> target/s390x/excp_helper.c | 3 +-
> target/s390x/mem_helper.c | 8 ----
> target/s390x/mmu_helper.c | 96
> +++++++++++++++++++++++++++++-----------------
> 3 files changed, 62 insertions(+), 45 deletions(-)
[...]
> diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
> index 9daa0fd8e2..44a15449d2 100644
> --- a/target/s390x/mmu_helper.c
> +++ b/target/s390x/mmu_helper.c
> @@ -106,6 +106,37 @@ static void trigger_page_fault(CPUS390XState *env,
> target_ulong vaddr,
> trigger_access_exception(env, type, ilen, tec);
> }
>
> +/* check whether the address would be proteted by Low-Address Protection */
> +static bool is_low_address(uint64_t addr)
> +{
> + return addr < 512 || (addr >= 4096 && addr < 4607);
> +}
I like the check from the kernel sources better:
static inline int is_low_address(unsigned long ga)
{
/* Check for address ranges 0..511 and 4096..4607 */
return (ga & ~0x11fful) == 0;
}
... that might result in slightly faster code (depending on the
compiler, of course).
Thomas