From patchwork Sun Oct 7 20:51:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 10629745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 833D915E2 for ; Sun, 7 Oct 2018 20:52:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70524288FD for ; Sun, 7 Oct 2018 20:52:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6256928AE0; Sun, 7 Oct 2018 20:52:48 +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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 F3F56288FD for ; Sun, 7 Oct 2018 20:52:47 +0000 (UTC) Received: from localhost ([::1]:43480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9G2g-0007HN-Oa for patchwork-qemu-devel@patchwork.kernel.org; Sun, 07 Oct 2018 16:52:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9G23-00070j-Ko for qemu-devel@nongnu.org; Sun, 07 Oct 2018 16:52:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g9G1y-0006WB-LO for qemu-devel@nongnu.org; Sun, 07 Oct 2018 16:52:07 -0400 Received: from mout.gmx.net ([212.227.15.18]:38165) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g9G1y-0006V2-B8 for qemu-devel@nongnu.org; Sun, 07 Oct 2018 16:52:02 -0400 Received: from ls3530.fritz.box ([92.116.168.42]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MXq3L-1gEMoO2DLz-00WlcV; Sun, 07 Oct 2018 22:51:55 +0200 Received: from ls3530.fritz.box ([92.116.168.42]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MXq3L-1gEMoO2DLz-00WlcV; Sun, 07 Oct 2018 22:51:55 +0200 Date: Sun, 7 Oct 2018 22:51:53 +0200 From: Helge Deller To: qemu-devel@nongnu.org Message-ID: <20181007205153.GA30270@ls3530.fritz.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-Provags-ID: V03:K1:WGqqY2ZGZR2XGjqpMCwrThNd5I2+H1B54ZtBPaMTTXhCh/LBa5C fazUxCjWcmL/3b8WETOJpeaZwcZyPEw9XHYIvGytcJdkPuiVep4plJZjlm1LF9PQw0gFSTV AY7XEz+LZvx02ywHIxSw8UtDysePySjBEFG+PofFCuOX6fckOLoJPNrz5eS0jhPJJXbg4uN RWMi62ZqOq1tfRT4gED/g== X-UI-Out-Filterresults: notjunk:1;V01:K0:A0NH0Ecn8xA=:0UiSDtI76IfK/JgFdx/Pws k2VtjF2/Z6eUA7TCA092FcpvDaDxgsKqceFNN4lFHXbr4miztSZiIROy4J0QrAKPHpnCW6vSK 0wy2zeeujDc7caxXDLrCasyVVw9jliM1wzI7M4/kZDGbTFofqGxEyHjB7O1nicQdo2NBjt0g8 RSxShKepaXIQ2HZClPK/EWXB7LYZnWeUNsRRKZop3/rXsEuRaWNhbQDWXLNJFDdh9n3g3Q6OC PXjGClrU2V3H7hJa7wPg8Wdn2PjKjulpElOlIwEZ/4xPuEhXF3tSJRIWsRxgENLJqbsldTSvn MgyeUaLxuHJkpsR65ndCcXBACePthqm6/wBJPQ6c5qbrUtx/Hz0rJ5keSs92VqhweyFZjZBd7 MMsEjjQPbeFEmkL7b4+HA1rg3ZQUA1tu4AHk44hvfJ1P+DZmhQjr4EmTVzQIouEOo5kgxAUO0 KZm3Jxxd+RixfwQnnWWXKu1AfnEexvdP82wzdOAYJLpyqSF+DnyqFFR0+KVXMoYg7PBdFTlMd stzXFirmXrf+OzQBH0Tj8GiLlC8TDtYZ50OZktBjGGZVAAvE9wBM2Hku6u9Hz3rFN4CiHMj9c DyR3cM8VDC/5s9zUvy/UjMbyqqGZNpXavKZoD7onOErq9bLZb4/gHqPQK7xQNuCaXbTU8pSA6 NaPlHBW/Xr7xrGNXP1tpaXChEKlKNXaSb0zImYekvE7E66ah8eQpMccwGZNBcMldnrVFBuL5C 4rRhFcx9sVNYXDAiBM60YC+NVf7Tz9m1RrUc0V8svBFg8XbRhDTIfl7YfAgJgUCXwBCi5y5fP VvvBfXZcBh7LRYnTiXGxGj+nQxJRA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.18 Subject: [Qemu-devel] [PATCH] qemu-system-hppa: Raise exception 26 on emulated hardware 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: Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On PCXS chips (PA7000, pa 1.1a), trap #18 is raised on memory faults, while all later chips (>= PA7100) generate either trap #26, #27 or #28 (depending on the fault type). Since the current qemu emulation emulates a B160L machine (with a PA7300LC PCX-L2 chip, we should raise trap #26 (EXCP_DMAR) instead of #18 (EXCP_DMP) on access faults by the Linux kernel to page zero. With the patch we now get the correct output (I tested against real hardware): Kernel Fault: Code=26 (Data memory access rights trap) (Addr=00000004) instead of: Kernel Fault: Code=18 (Data memory protection/unaligned access trap) (Addr=00000004) Signed-off-by: Helge Deller diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index ab160c2a74..aecf3075f6 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -137,7 +137,8 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, if (unlikely(!(prot & type))) { /* The access isn't allowed -- Inst/Data Memory Protection Fault. */ - ret = (type & PAGE_EXEC ? EXCP_IMP : EXCP_DMP); + ret = (type & PAGE_EXEC ? EXCP_IMP : + prot & PAGE_READ ? EXCP_DMP : EXCP_DMAR); goto egress; }