From patchwork Thu May 16 22:35:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 164349 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1409488ili; Thu, 16 May 2019 15:36:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxUnLsebY7u5sbWwTadAwbwvAjrkhZCP8ppkgPQrodxmfOvO/W06rd9UPHMrP4qwWEyzs1 X-Received: by 2002:a17:906:ccd8:: with SMTP id ot24mr5947124ejb.263.1558046165639; Thu, 16 May 2019 15:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558046165; cv=none; d=google.com; s=arc-20160816; b=fwjrU/kkauz0The4wgZMiicFx9cdDZDb3nZwGxCkRIVBfJEf+VDXVpZ274w9dHB+/h u7SH2q6EubVu9VK/85+vYWeOsLXL0nFK4r4mWEIQ5mvq82zcZzt7//hSdMNe0eVYB8uc As23B9hn0ZXeikBzcYBViqfTTNouYYOAXmxj83pazEPJNjf3K5ZKijbKwNZ2RLmT77AK Vyw6fXbAVAt6sdowYBWDFPuZzAZE6FvJanWbaVjtBzLnKGs8I35jtifJqaqKR0HRhK8y FwT5pHdNdhWAzVtaBCwIWtvoekNuaI+aveF3UQl4xTUaB4ABQ8KGwh0HbSOl97uKkyVc nG4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=H4SqUdOe/VWB3vy415twPL5ofpTFr2ffEkJNbbQNHUE=; b=g8K4mWfP0A1VxZvO5YEOsi9WGbuiIu7pmTrOWWaS11EW3T3ZsJxIQyKFrh+uVWkO03 3Ab7QIHPfDG6+QbzOUDqGk5XcEIhFpWHk8rRzo24/WEe4fsI/VRhxR4rFyEPQowLgPX6 4uHIG/P6xDrDoNj2+GOWuc2B2amqISzcYgnZcxviZ+6GRCP1xh4pAUPkAi8oVN4iScmh hYAbl6E/UjUbHph1fQiUGhjLSfNJyZJY6HptyUcKIoEmyiqxexUY/oH0+HBLUr3Iu1Lb cXhWDbEOoqWiVR8+XGv53mcWA3F75i0zNgzOmFgUmtDq0tea1ZbO6J3KCJ8iHjwnN6+I ErYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s53si5318291eda.46.2019.05.16.15.36.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 16 May 2019 15:36:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:37739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hROyq-0005s0-Ii for patch@linaro.org; Thu, 16 May 2019 18:36:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hROyP-0005qY-82 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 1hROyO-00024i-3H for qemu-devel@nongnu.org; Thu, 16 May 2019 18:35:37 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:49137) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hROyN-000207-QL for qemu-devel@nongnu.org; Thu, 16 May 2019 18:35:36 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N6bsG-1gc2OY0DJm-01861d; Fri, 17 May 2019 00:35:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 00:35:14 +0200 Message-Id: <20190516223519.7520-2-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 X-Provags-ID: V03:K1:mD9HteA2IFi9s1K5T83VMGrv0hpvBwVXoe9rDB5eXNP/haHwuQt cYN9bBB/2YWBVsEnn8j2y/4o1VsYtmMtYXLm6yh+Dh7Eh3R38wA8pEcClSJHh4W1UCpHrRA /xbxgCS4TZpSUgdVp8YlqdcfJ+wtrcn3X6SoQeCNzZEWgopPJVWjwAubR0bGmo3hfYsdvz2 5P1XATwrPFIZ6aQAkA7vw== X-UI-Out-Filterresults: notjunk:1; V03:K0:zwm4bP9DNDE=:L6PDi8m94BmOKcfPkmct3D QtV7DQyhqm8PlzRNYi/Kc12pZ+27Rs9EfqFcprN/UVngIZjOKtUI/GVRDkYNFzuydxpCNytMK p52+/cRqOwm4wCJ981J4k6SOYt3UwWVMAG1C6ngUyNEMOei7SO/vjAA08mnCt5Nu0QdI4drmn fmZGiTGgKrJBwy8bBCpLfivh+FlGuKe9L0ptWjaLTCzssZk+LH8NQ0Zgammw2UcYDJx72xo8S 4s5pJvAcoT3YJ3BC38dm0+yiPd5A+Ck/cwv5xRqo1F/bMyAJ9ftYsbG46vwoeAScdcb4tar4P YzQAMCNQcxx9u0K/PFWkqfaN0d/FWIsR7g0qpIWoFn2TRhMh5lfsVFWLD5Zff4atJMGoxSeCu e5SEy60BDNnSk1wHg+wotH7RgJEhpkgyGPub3UQPosbs1HVTL0wFrSEAqIKwNRPBlg7tydb5O ZLMmPp7LCZoTslvl2NYJi5UT+Nc6NqRftZTVybIZ5VhXDVhQ40pi4QegPd4a0syLYeniANy5q pmns3GX9FtTPUn1ifNEO7bft1+QLJoiBYeP2QLPtjpVjzPciycp/ADCJ5LEEYpUoyshG0hioB CxxsU1AbPcQ9zkWF0HpWSxsDi7GIsdb42jOlnEgVb8VqZIM26L+unr3odidd6u+UKx/HDzMfP MO9Ydv2NAXWs5jEmKSI+HD7RZFq2ryNJ8fxwFWoZZbMwa4GCuT2I/l6tglJ6dzMzymFGQ1Dwe P/K+6u9Z+QyuJeTphb2z85LKVTyGSFz65habUg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.10 Subject: [Qemu-devel] [PULL 1/6] target/m68k: In dump_address_map() 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In dump_address_map(), use address_space_ldl() instead of ldl_phys(). This allows us to check whether the memory access failed. Signed-off-by: Peter Maydell Message-Id: <20181210165636.28366-2-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- target/m68k/helper.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/target/m68k/helper.c b/target/m68k/helper.c index d958a34959..5b81995ee7 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -403,6 +403,7 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) int last_attr = -1, attr = -1; M68kCPU *cpu = m68k_env_get_cpu(env); CPUState *cs = CPU(cpu); + MemTxResult txres; if (env->mmu.tcr & M68K_TCR_PAGE_8K) { /* 8k page */ @@ -416,22 +417,29 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) tib_mask = M68K_4K_PAGE_MASK; } for (i = 0; i < M68K_ROOT_POINTER_ENTRIES; i++) { - tia = ldl_phys(cs->as, M68K_POINTER_BASE(root_pointer) + i * 4); - if (!M68K_UDT_VALID(tia)) { + tia = address_space_ldl(cs->as, M68K_POINTER_BASE(root_pointer) + i * 4, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK || !M68K_UDT_VALID(tia)) { continue; } for (j = 0; j < M68K_ROOT_POINTER_ENTRIES; j++) { - tib = ldl_phys(cs->as, M68K_POINTER_BASE(tia) + j * 4); - if (!M68K_UDT_VALID(tib)) { + tib = address_space_ldl(cs->as, M68K_POINTER_BASE(tia) + j * 4, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK || !M68K_UDT_VALID(tib)) { continue; } for (k = 0; k < tic_size; k++) { - tic = ldl_phys(cs->as, (tib & tib_mask) + k * 4); - if (!M68K_PDT_VALID(tic)) { + tic = address_space_ldl(cs->as, (tib & tib_mask) + k * 4, + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK || !M68K_PDT_VALID(tic)) { continue; } if (M68K_PDT_INDIRECT(tic)) { - tic = ldl_phys(cs->as, M68K_INDIRECT_POINTER(tic)); + tic = address_space_ldl(cs->as, M68K_INDIRECT_POINTER(tic), + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK) { + continue; + } } last_logical = logical; From patchwork Thu May 16 22:35:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 164351 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1411319ili; Thu, 16 May 2019 15:38:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKORNUJvxdTiz5kDkv3wViti0U/j13JON8Z1u+6cvwMNuARWNgPoJY+YCspqkqh73pZAz8 X-Received: by 2002:a17:906:2887:: with SMTP id o7mr40666549ejd.249.1558046302319; Thu, 16 May 2019 15:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558046302; cv=none; d=google.com; s=arc-20160816; b=MMpaMwvEsq0+h1LgiR8BaHTsRFnGi471bH1aCWXFqtb6X3A9ZOTRRafKUDhKIZem5W j6VufPmTIsLxg0BRYtC0OzvYlS0vi0ZtkH3qnPj6ugV7ydiMX/hIpOwiB0PAYePurF8z 7frDuQpSL2gocqFMALQBfrO0hM2YkwqHfXSfgRhJYHATQCB+DID+ctDXeRumwuwFVJSz QmOsFXtU20V0SptXKw6bFEofzxFGkmei/nxuw2k221/Hw+9BPtfhoQlc613BqKolsiRe BeTeynnIWtkuUmfenS4rf8Z6cp7/lEE6yfeFUKZRYPRwbN5fxG8u3sERRB2cGV/XHx5A WMZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=xNKImjOqaEN/AYAPXCRClwjWEsshT6FarOZUIMwQR8Y=; b=EfP48WKLtZbtKhJrGn3bpzg2cmx9zPYm849xYmJpYl3OVeE1eX730neIJyA5rJaoZv r4jxiGc3eQzKnhCS4gS4umgbM9ETgAbx5JPFhA93WVrQyOSgellYzLFgOPmoPF3CcFDQ fDN6hXM7aBDvyzDZtdJttoR0RIUTPn2goEIXA+mhwUy2TVpopInlmC57HFKO5zy6fzXx hF0Oh/pe6cc4wLjR2sUdjcUBPvsi4/LQNdjq1IuT7oRu38eHVvOSwUb2gCc5zUckVmIk WMMD9zI8+xd2du3Ek3iYrySvly1Ta7zvW5ksX8DTGAMEeHGi7UFd4guWvPDdYsGCkz3m P6Rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f49si4768755eda.354.2019.05.16.15.38.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 16 May 2019 15:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:37755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRP13-0007op-7I for patch@linaro.org; Thu, 16 May 2019 18:38:21 -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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.20.1 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, hwaddr *physical, bool debug = access_type & ACCESS_DEBUG; int page_bits; int i; + MemTxResult txres; /* Transparent Translation (physical = logical) */ for (i = 0; i < M68K_MAX_TTR; i++) { @@ -680,12 +681,19 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical, /* Root Index */ entry = M68K_POINTER_BASE(next) | M68K_ROOT_INDEX(address); - next = ldl_phys(cs->as, entry); + next = address_space_ldl(cs->as, entry, MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != 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 != 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, hwaddr *physical, /* Pointer Index */ entry = M68K_POINTER_BASE(next) | M68K_POINTER_INDEX(address); - next = ldl_phys(cs->as, entry); + next = address_space_ldl(cs->as, entry, MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != 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 != 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, hwaddr *physical, entry = M68K_4K_PAGE_BASE(next) | M68K_4K_PAGE_INDEX(address); } - next = ldl_phys(cs->as, entry); + next = address_space_ldl(cs->as, entry, MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != MEMTX_OK) { + goto txfail; + } if (!M68K_PDT_VALID(next)) { return -1; } if (M68K_PDT_INDIRECT(next)) { - next = ldl_phys(cs->as, M68K_INDIRECT_POINTER(next)); + next = address_space_ldl(cs->as, M68K_INDIRECT_POINTER(next), + MEMTXATTRS_UNSPECIFIED, &txres); + if (txres != 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 != MEMTX_OK) { + goto txfail; + } } } else if ((next & (M68K_DESC_MODIFIED | M68K_DESC_USED)) != (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 != 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 != MEMTX_OK) { + goto txfail; + } } } @@ -776,6 +810,14 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical, } 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; } hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) From patchwork Thu May 16 22:35:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 164350 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1411183ili; Thu, 16 May 2019 15:38:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9DghLMat7TeR8a0Rv+dcNsKe2YczxLVKWycZBRvktoMgiCMhfisr+/3KUA0vaLAgIMqlp X-Received: by 2002:a17:906:abd9:: with SMTP id kq25mr26077885ejb.30.1558046292255; Thu, 16 May 2019 15:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558046292; cv=none; d=google.com; s=arc-20160816; b=ORvT01XU0pWYp5LDkxsn3vrzf3MSx7pueujlGfbSevj681jC76w9H11dosuCvg1V52 1DpIcm7JSfJbgf1QWjic8KRxjpkV5XfCZeWdYY5K/X1bu5t7Jau2mLL2dXI5hk/I0HML BT4hw8VAHCpf7sTyqGhZfjPE5bhhUC9xSKHqQSjdoZuTbH07w/L1hdzk16XaMElMCgSO M7s4uPoyG7gFIwYEnQLWTp57pjNczTFe+pGsMHoICT7e+iGtNfs6TlupqTI5caadXAYE DpdXv/6RyV7otq+FIe89yambDUCOJyBWQteHTnPCMpVWliI6hEWbBF7ApijCTIx7xwH6 WCkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=Fml6nIj9ueFvZUVdjU3o7jpp91ZDvYOWWyz1dAgkAKc=; b=FtjlgbqexWkhJfhI8CHlFmXp0T3Rh4Mh8QEwsgWhUO2oZ/eHHh8kbrFjHH1MmlrAp6 IZgL9vpzopmljlZ7e/9xnaaObOCat/InIutxGjM78uttupl2a03+IOaGmDMaSBCgod6w mKvewAfnmclXi/TrgzRQ1zPFeaLwSKjmumURLCEdfFvbcCEzBhFuaYv26y7o6bxa+bmj rohMyPfvyL5qqq9PbB6Vi8wrva3+t23utKj9K/qj8U7hd+Y1JoNm4ACehJ7XIOIBlDrq YrjlXLrKUPuplCd3wxGuN/NoeBwowcNdgp2kkGAYY79mFb9r6dwIlZjZ1CGRk/kZxr4h OFOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d14si4664590edp.306.2019.05.16.15.38.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 16 May 2019 15:38:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:37759 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRP0t-0007t2-6B for patch@linaro.org; Thu, 16 May 2019 18:38:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hROyO-0005qV-Tc 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-00023U-PL for qemu-devel@nongnu.org; Thu, 16 May 2019 18:35:36 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60019) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hROyN-0001zi-FQ 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 1MBUuP-1hX9C60p1b-00CzGe; Fri, 17 May 2019 00:35:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 00:35:16 +0200 Message-Id: <20190516223519.7520-4-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 X-Provags-ID: V03:K1:l9C8KLvBW2gomwO+cpQLeYlEVNz3HseGsRFns7bsiU+O6tkAfy5 k5eGTtSxtfBicIOjZ+tSGRY40Rpqn1EKPhDfuSQ7WXFCJ9Pl3CZ39a51u1SUn2mpPLvq8/b Kbk7lw1eDPMAcTIg4OFdZHNFK2TaVzRSgGlDK2SVats0o5DZFxTkwmk+H9sSfl9r4UzJHVS f11z2bBpZ+9jaXFZKmXSw== X-UI-Out-Filterresults: notjunk:1; V03:K0:KuBjqcR/sak=:YFalkuBsw0/Jgukd69HVaS kqKHfK9UpnHcYDiT+wqN5/tBNp1dqCtpPS0tlU1vnJ57a+PKwVBR6Y9ryU2c5Fr9ka7q5MfDt 9i3GbWOaUf+FXLKNLjkuEuBbgQyixNm2+FVX0SIX6yllhXqp3xZwKqdZi+gTrYgHGOkfghr+3 A4OoErNP48zHBZb2tDGiW1wb/MGZNVW/IfnwCOWvknetxBV37UzC37iKCWrMCPiOvrJM3Ox2l M5zeWCHc6+FxfVjeHlfFPxGgOvCMvshZDDbz9jS4dx8QWJzLvNibK+H69FKIFNvIZkMyqw6Gi T7nkxz9fgGxkITmNx1WrqSW65f2a1UP8K9qcBu93+lPOQ+IlTe2wT9ENNohc0pOv8o8rWVwo0 LHZCTOQ6I96EQV9dWnAEaMsRRdTPERNtCmZ6IvlRjCpyueK9Y68WsPFPAs1kY8TZhWunnc+5j aj6bNiUp6mbkhUQ3UCKXErBf1ibyVsg4UMiFHJwe3nlxWHPRYHQrEe9MYgsHWs2UnIp07js0m bv9E1dtWH2zQbRLPO+tORJ1TMcd7+tBfAnkaT8/3GPCm0o2zCjE0TXWvp5YVMSFAXr36E5Xw6 yCyVRgkf+dim6prNADyixP8evFFD//4+ig9bplBdcftvavxfrHPUrWfEI+7h6W+JqjNQWyrsq V2CHGw4N+AJtK9kYavf9cY3zR8e4GC19GjPkJoWXoe1SgG3OLmRR7aAeKkkRJS+s4RWqo6Xhl 0wdcL/fQtGha/TuiKGJxB6ldOl7qKUauqn5V9A== 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 3/6] target/m68k: Switch to transaction_failed hook 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Switch the m68k target from the old unassigned_access hook to the transaction_failed hook. The notable difference is that rather than it being called for all physical memory accesses which fail (including those made by DMA devices or by the gdbstub), it is only called for those made by the CPU via its MMU. (In previous commits we put in explicit checks for the direct physical loads made by the target/m68k code which will no longer be handled by calling the unassigned_access hook.) Signed-off-by: Peter Maydell Message-Id: <20181210165636.28366-4-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- target/m68k/cpu.c | 2 +- target/m68k/cpu.h | 7 ++++--- target/m68k/op_helper.c | 20 ++++++++------------ 3 files changed, 13 insertions(+), 16 deletions(-) -- 2.20.1 diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 582e3a73b3..6d09c630b0 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -271,7 +271,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->gdb_write_register = m68k_cpu_gdb_write_register; cc->handle_mmu_fault = m68k_cpu_handle_mmu_fault; #if defined(CONFIG_SOFTMMU) - cc->do_unassigned_access = m68k_cpu_unassigned_access; + cc->do_transaction_failed = m68k_cpu_transaction_failed; cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; #endif cc->disas_set_info = m68k_cpu_disas_set_info; diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index ad41608341..6039b47d0c 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -544,9 +544,10 @@ static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch) int m68k_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, int mmu_idx); -void m68k_cpu_unassigned_access(CPUState *cs, hwaddr addr, - bool is_write, bool is_exec, int is_asi, - unsigned size); +void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, + unsigned size, MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retaddr); #include "exec/cpu-all.h" diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 76f439985a..1c272b4cda 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -454,19 +454,15 @@ static inline void do_interrupt_m68k_hardirq(CPUM68KState *env) do_interrupt_all(env, 1); } -void m68k_cpu_unassigned_access(CPUState *cs, hwaddr addr, bool is_write, - bool is_exec, int is_asi, unsigned size) +void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, + unsigned size, MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retaddr) { M68kCPU *cpu = M68K_CPU(cs); CPUM68KState *env = &cpu->env; -#ifdef DEBUG_UNASSIGNED - qemu_log_mask(CPU_LOG_INT, "Unassigned " TARGET_FMT_plx " wr=%d exe=%d\n", - addr, is_write, is_exec); -#endif - if (env == NULL) { - /* when called from gdb, env is NULL */ - return; - } + + cpu_restore_state(cs, retaddr, true); if (m68k_feature(env, M68K_FEATURE_M68040)) { env->mmu.mmusr = 0; @@ -476,7 +472,7 @@ void m68k_cpu_unassigned_access(CPUState *cs, hwaddr addr, bool is_write, if (env->sr & SR_S) { /* SUPERVISOR */ env->mmu.ssw |= M68K_TM_040_SUPER; } - if (is_exec) { /* instruction or data */ + if (access_type == MMU_INST_FETCH) { /* instruction or data */ env->mmu.ssw |= M68K_TM_040_CODE; } else { env->mmu.ssw |= M68K_TM_040_DATA; @@ -494,7 +490,7 @@ void m68k_cpu_unassigned_access(CPUState *cs, hwaddr addr, bool is_write, break; } - if (!is_write) { + if (access_type != MMU_DATA_STORE) { env->mmu.ssw |= M68K_RW_040; }