From patchwork Wed Jun 7 00:30:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9770407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C08F560353 for ; Wed, 7 Jun 2017 01:02:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A20A0269A3 for ; Wed, 7 Jun 2017 01:02:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 964E9284A8; Wed, 7 Jun 2017 01:02:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EBD09269A3 for ; Wed, 7 Jun 2017 01:02:08 +0000 (UTC) Received: from localhost ([::1]:40685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIPMO-00059E-1j for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Jun 2017 21:02:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIOtX-0003B7-QF for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIOtW-00027Y-ND for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:19 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:33817) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIOtW-00027S-Ik for qemu-devel@nongnu.org; Tue, 06 Jun 2017 20:32:18 -0400 Received: by mail-qk0-x242.google.com with SMTP id d14so12248463qkb.1 for ; Tue, 06 Jun 2017 17:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=MzN6WgQr71L2/xXK27EE1KtDv4KAeHjvgEGGF0GV0Sw=; b=CTlu/7w40NMwFriDyPd01bW/Jp8xMGThgmaf+zyHtHjy2ZeIAMnZgDn3F4sfkuF4dX KwPvxr0VWvcH4wWkw6iTetrN4JeKxKF+PiHXK46HYujdBouTgLZcJxtJYSk9hdhIG/DX amD2655n29RPtfvuhtC88ATLKbV10UozaDht91nv4N+1ragbmWTN7xS2fALmN+xwxpSs ZHdV+pJB+7TTwAXK4yRSNqLke8huEqgAX5bmIijV0g+/Opup7Ind25H3rMy96jpV/8Ib nY3kQ+gksm935AOrK4el7nqa6G0frlg4PyRgnbxQIAr3UQTkvo/jm5gFZ1/TGDHk7vEk yJaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=MzN6WgQr71L2/xXK27EE1KtDv4KAeHjvgEGGF0GV0Sw=; b=rTMqSCwiJiL2Ha6dO9Xyq1QXqtdYTriP1VsJnUUItyAIAAGR6LjyQzJP7oK22Rns3/ Ki/Pd6eOIZWRcKhrrvO+VeHz4PJZ9M1+6MFbqXemgD4xFoCAfs331Mm5grMhrkyemInl 22ynrn1iUsPg+WJdzzJ/IZSRb9D6G6wgtoxoIMUgiUfvLYXaxkITD1DGwap3XBaQjVGA +t44TjyVwDAn7EErf5SzSVYQpz4F3fDDiKKtDkBc93pj+sw53Jsb99fqDidMUJ0SalEQ moq1jAikWUqtEogs92vYTmZI4ojLNGrylUm6MIsojdNlVo81iTniK+Dl4zNDBCX5EWXO OOrQ== X-Gm-Message-State: AODbwcA7VEGRGQ8T+Y3oLZY7y5ulzpBZfj184CzeehMEqQjLnCmlRAv5 o9P3PVwPlMakRaRLdSE= X-Received: by 10.55.201.68 with SMTP id q65mr35711772qki.249.1496795537877; Tue, 06 Jun 2017 17:32:17 -0700 (PDT) Received: from bigtime.twiddle.net.com (71-217-91-69.tukw.qwest.net. [71.217.91.69]) by smtp.gmail.com with ESMTPSA id m47sm29286qtc.36.2017.06.06.17.32.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 17:32:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 6 Jun 2017 17:30:50 -0700 Message-Id: <20170607003119.14778-42-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170607003119.14778-1-rth@twiddle.net> References: <20170607003119.14778-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PULL v2 41/70] target/s390x: remove some Linux assumptions from IPTE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Aurelien Jarno Signed-off-by: Aurelien Jarno Message-Id: <20170531220129.27724-3-aurelien@aurel32.net> Signed-off-by: Richard Henderson --- target/s390x/cpu.h | 2 ++ target/s390x/mem_helper.c | 17 ++++++++++------- target/s390x/mmu_helper.c | 2 -- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index fdb2f50..a4d31df 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -1035,6 +1035,8 @@ struct sysib_322 { #define _SEGMENT_ENTRY_RO 0x200 /* page protection bit */ #define _SEGMENT_ENTRY_INV 0x20 /* invalid segment table entry */ +#define VADDR_PX 0xff000 /* page index bits */ + #define _PAGE_RO 0x200 /* HW read-only bit */ #define _PAGE_INVALID 0x400 /* HW invalid bit */ #define _PAGE_RES0 0x800 /* bit must be zero */ diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index e35571e..0ebd65d 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1073,19 +1073,22 @@ uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2) } /* invalidate pte */ -void HELPER(ipte)(CPUS390XState *env, uint64_t pte_addr, uint64_t vaddr) +void HELPER(ipte)(CPUS390XState *env, uint64_t pto, uint64_t vaddr) { CPUState *cs = CPU(s390_env_get_cpu(env)); uint64_t page = vaddr & TARGET_PAGE_MASK; - uint64_t pte = 0; + uint64_t pte_addr, pte; /* XXX broadcast to other CPUs */ - /* XXX Linux is nice enough to give us the exact pte address. - According to spec we'd have to find it out ourselves */ - /* XXX Linux is fine with overwriting the pte, the spec requires - us to only set the invalid bit */ - stq_phys(cs->as, pte_addr, pte | _PAGE_INVALID); + /* Compute the page table entry address */ + pte_addr = (pto & _SEGMENT_ENTRY_ORIGIN); + pte_addr += (vaddr & _VADDR_PX) >> 9; + + /* Mark the page table entry as invalid */ + pte = ldq_phys(cs->as, pte_addr); + pte |= _PAGE_INVALID; + stq_phys(cs->as, pte_addr, pte); /* XXX we exploit the fact that Linux passes the exact virtual address here - it's not obliged to! */ diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c index 31eb9ef..501e390 100644 --- a/target/s390x/mmu_helper.c +++ b/target/s390x/mmu_helper.c @@ -143,8 +143,6 @@ static int mmu_translate_pte(CPUS390XState *env, target_ulong vaddr, return 0; } -#define VADDR_PX 0xff000 /* Page index bits */ - /* Decode segment table entry */ static int mmu_translate_segment(CPUS390XState *env, target_ulong vaddr, uint64_t asc, uint64_t st_entry,