From nobody Tue Feb 10 11:55:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1558046370; cv=none; d=zoho.com; s=zohoarc; b=CDA38r5yWVeFmwveRdUon/KtnKiz1594OJfbSf2GuwPtCLj25Tp7e6C+cSuxqPZpgg0XSUtBaVcB+1XNq1lJHF3ZNC5PI+LcPHCdOTVSHzGo5RjHMwcH37ITYcefN8gRVHR1sB6pphUlTl1V0M6sO5JXU4qCJNiU7hw2p1OlJ/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558046370; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=xNKImjOqaEN/AYAPXCRClwjWEsshT6FarOZUIMwQR8Y=; b=L/nGNM+apZS7ThKGBLP0Ljote8w+Y7lxNpk6G5vqWhHaMO0zIGKeRu+x6ZDPwi+OoCnp/OUblrYjY0JCDJTwi5QJfVNJkHpGMKzWmrlIXt4q8FL8+Izo9SSTpRmZ7nBBjVBuiw2uIo8ixslzWbR4sOtF2VFXNOu99chfg7J7Doo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558046370775943.0237312517759; Thu, 16 May 2019 15:39:30 -0700 (PDT) Received: from localhost ([127.0.0.1]:37761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRP24-0008QU-Kv for importer@patchew.org; Thu, 16 May 2019 18:39:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hROyP-0005qX-7t for qemu-devel@nongnu.org; Thu, 16 May 2019 18:35:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hROyN-00023Z-Ph for qemu-devel@nongnu.org; Thu, 16 May 2019 18:35:37 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:34667) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hROyN-0001zj-Fy for qemu-devel@nongnu.org; Thu, 16 May 2019 18:35:35 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MXY2T-1hB6672YX9-00Z2OC; Fri, 17 May 2019 00:35:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 00:35:15 +0200 Message-Id: <20190516223519.7520-3-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190516223519.7520-1-laurent@vivier.eu> References: <20190516223519.7520-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Wst5CG7txb52InukpGjmYIqgpKtQBEZ9xOoRzes4il0BZ+Jl7y4 6fR6iXYPNBxE3fhnPzaqS0Rrr4pNWioKfeHIJUgcxg0YhdkvPgZukYZ1YTRqRh1ellzsiK9 dc0M7Ej16rJDoIkD/BLzFep3uX3HlDOLFkCT3F2/d0BCSjGa7zskJp67G9ranY9y5i6lmzB qzMRBcF9YdnEWq2B6MUbg== X-UI-Out-Filterresults: notjunk:1;V03:K0:2z7gLuM97CE=:fzEU6IrtDr6eW0MevMd0qw jHtSfJrWN/9rEd6XProGArOiwJP4WEZLas8W4NREUzX2OExMSDA0nP1xXlAR2zF0cW1KWnw2P ydINB3B9TeHqcAsvXnZ99EGSu5bu4cD++DRtzE7PPp2NezuxgAsPhJHXxUoq1oeAizYnN8Fxe t4b/33Dr9aMuMmMyzJPa5DkuMzJs1wRaBklwnnV7nnT+73/HMEuN94pg1GfZcDpSEH7/KmF21 6R9btUw1pYcQ05Cv750g1pj1rDC0o6HvmpSm/4K5v1kXkqeb3EwoemORTci9iSiRLti9jpgRN GWFwRZzLi3V8DBobHNDIeVJtu+Bugyh2dUgF2MPLnScj1gkZuwBW6nKCAjfOBguPa/ofcsdP/ nb0Agxhe2vC9RBNw712DGhpmOWqvZ/U+D0WDqzlT6ak44EbBLZHoAjIxZ5nJ8vsz3FxlPuSz4 HmJMcu8FTkiPKYN1nE7EyrlDoe1iXYYCIltWycnrcKGnZTja15spsc9+VQPzMk+ngheC4mZaM aEsvKxQOM8AANySMo1/Ymp3LYxGuBcKJdNWbIUx/411XX5PIt+EHdZQsMs3KjXScF2kaaTkNZ VSe09WS4lNJFPPs6YP/8pxpFKuXJnHjSK8J1U4eQasKSNm10bk55zwkzAg56BQ9a1QU6kAQ6O hPh9AlDrE1OPZifh8u4Xwqnmy/WefHLdEhFCFVQgTX/HHHMQLRXpDvMSTmbjV5gKDqfxWLDQU TZMkImnRka8tO6AJLQOzIT4UJcd5WZPZTX8VUA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.73 Subject: [Qemu-devel] [PULL 2/6] target/m68k: In get_physical_address() check for memory access failures 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: Thomas Huth , Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Peter Maydell In get_physical_address(), use address_space_ldl() and address_space_stl() instead of ldl_phys() and stl_phys(). This allows us to check whether the memory access failed. For the moment, we simply return -1 in this case; add a TODO comment that we should ideally generate the appropriate kind of fault. Signed-off-by: Peter Maydell Message-Id: <20181210165636.28366-3-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- target/m68k/helper.c | 62 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 5b81995ee7..edd7bb64ed 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -651,6 +651,7 @@ static int get_physical_address(CPUM68KState *env, hwad= dr *physical, bool debug =3D access_type & ACCESS_DEBUG; int page_bits; int i; + MemTxResult txres; =20 /* Transparent Translation (physical =3D logical) */ for (i =3D 0; i < M68K_MAX_TTR; i++) { @@ -680,12 +681,19 @@ static int get_physical_address(CPUM68KState *env, hw= addr *physical, /* Root Index */ entry =3D M68K_POINTER_BASE(next) | M68K_ROOT_INDEX(address); =20 - next =3D ldl_phys(cs->as, entry); + next =3D address_space_ldl(cs->as, entry, MEMTXATTRS_UNSPECIFIED, &txr= es); + if (txres !=3D MEMTX_OK) { + goto txfail; + } if (!M68K_UDT_VALID(next)) { return -1; } if (!(next & M68K_DESC_USED) && !debug) { - stl_phys(cs->as, entry, next | M68K_DESC_USED); + address_space_stl(cs->as, entry, next | M68K_DESC_USED, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres !=3D MEMTX_OK) { + goto txfail; + } } if (next & M68K_DESC_WRITEPROT) { if (access_type & ACCESS_PTEST) { @@ -700,12 +708,19 @@ static int get_physical_address(CPUM68KState *env, hw= addr *physical, /* Pointer Index */ entry =3D M68K_POINTER_BASE(next) | M68K_POINTER_INDEX(address); =20 - next =3D ldl_phys(cs->as, entry); + next =3D address_space_ldl(cs->as, entry, MEMTXATTRS_UNSPECIFIED, &txr= es); + if (txres !=3D MEMTX_OK) { + goto txfail; + } if (!M68K_UDT_VALID(next)) { return -1; } if (!(next & M68K_DESC_USED) && !debug) { - stl_phys(cs->as, entry, next | M68K_DESC_USED); + address_space_stl(cs->as, entry, next | M68K_DESC_USED, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres !=3D MEMTX_OK) { + goto txfail; + } } if (next & M68K_DESC_WRITEPROT) { if (access_type & ACCESS_PTEST) { @@ -724,27 +739,46 @@ static int get_physical_address(CPUM68KState *env, hw= addr *physical, entry =3D M68K_4K_PAGE_BASE(next) | M68K_4K_PAGE_INDEX(address); } =20 - next =3D ldl_phys(cs->as, entry); + next =3D address_space_ldl(cs->as, entry, MEMTXATTRS_UNSPECIFIED, &txr= es); + if (txres !=3D MEMTX_OK) { + goto txfail; + } =20 if (!M68K_PDT_VALID(next)) { return -1; } if (M68K_PDT_INDIRECT(next)) { - next =3D ldl_phys(cs->as, M68K_INDIRECT_POINTER(next)); + next =3D address_space_ldl(cs->as, M68K_INDIRECT_POINTER(next), + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres !=3D MEMTX_OK) { + goto txfail; + } } if (access_type & ACCESS_STORE) { if (next & M68K_DESC_WRITEPROT) { if (!(next & M68K_DESC_USED) && !debug) { - stl_phys(cs->as, entry, next | M68K_DESC_USED); + address_space_stl(cs->as, entry, next | M68K_DESC_USED, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres !=3D MEMTX_OK) { + goto txfail; + } } } else if ((next & (M68K_DESC_MODIFIED | M68K_DESC_USED)) !=3D (M68K_DESC_MODIFIED | M68K_DESC_USED) && !debug= ) { - stl_phys(cs->as, entry, - next | (M68K_DESC_MODIFIED | M68K_DESC_USED)); + address_space_stl(cs->as, entry, + next | (M68K_DESC_MODIFIED | M68K_DESC_USED), + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres !=3D MEMTX_OK) { + goto txfail; + } } } else { if (!(next & M68K_DESC_USED) && !debug) { - stl_phys(cs->as, entry, next | M68K_DESC_USED); + address_space_stl(cs->as, entry, next | M68K_DESC_USED, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres !=3D MEMTX_OK) { + goto txfail; + } } } =20 @@ -776,6 +810,14 @@ static int get_physical_address(CPUM68KState *env, hwa= ddr *physical, } =20 return 0; + +txfail: + /* + * A page table load/store failed. TODO: we should really raise a + * suitable guest fault here if this is not a debug access. + * For now just return that the translation failed. + */ + return -1; } =20 hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) --=20 2.20.1