From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxtSA-0000jT-CE for qemu-devel@nongnu.org; Fri, 29 Sep 2017 07:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxtS4-0006M3-FV for qemu-devel@nongnu.org; Fri, 29 Sep 2017 07:27:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39220) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxtS4-0006KC-5v for qemu-devel@nongnu.org; Fri, 29 Sep 2017 07:27:28 -0400 Date: Fri, 29 Sep 2017 13:27:17 +0200 From: Cornelia Huck Message-ID: <20170929132717.23ecf350.cohuck@redhat.com> In-Reply-To: <3d5ea6d8-b3bf-b1a5-b4a1-082ff49ae842@redhat.com> References: <20170927170027.8539-1-david@redhat.com> <20170927170027.8539-3-david@redhat.com> <466fa6a0-ac91-66aa-aabb-a15a8ac62e0f@redhat.com> <3d5ea6d8-b3bf-b1a5-b4a1-082ff49ae842@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 2/3] s390x/tcg: low-address protection support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Hildenbrand Cc: Thomas Huth , qemu-devel@nongnu.org, Christian Borntraeger , Alexander Graf , Richard Henderson List-ID: On Thu, 28 Sep 2017 15:08:11 +0200 David Hildenbrand wrote: > On 28.09.2017 06:50, Thomas Huth wrote: > > 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 > >> --- > >> 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). > > I think that lim (readability) -> 0. Without that comment you're at > first sight really clueless what this is about. > > My check exactly corresponds to the wording in the PoP (and smart > compilers should be able to optimize). > > But I don't have a strong opinion on this micro optimization. FWIW, I'd be happy with both, but has anyone actually looked at the generated code?