From nobody Mon Apr 29 00:52:14 2024 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564761993; cv=none; d=zoho.com; s=zohoarc; b=KCydpxa9j3mc5Yf2PmEn0z0e3IUYxQxjWXXWHlBr1JbavwSMjJjA8e2D7op3wqHaLHJqJIrnUckHstKUNbIdLD7/AzY0G+CvMx9kuCh4GGI2Mo9skgr6GAmuaHoo5kGWGCDb+nZxh6H5cyW0iyCmYoHdbFSnV5XNsHv16ctb3bA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564761993; 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=BfQH4lRAqpmkXsMJ0tZi39/pftehOKqOJC/urrgU2h8=; b=DfGi0YpWkbRNS/S6DRZY1J+xvoPv0NcPeOwagrqzGz0R6PeFmo9az/jn3m7NiD62WxHlhlBx4BqVPKr9j1o70zqjRb7zrItKq1NsT6SR82hOM+Ciwv95zppilaCro+9mJMLYczSGpsPed15ja3ft/yUTNFFpTPkpyWOQlkm2ALo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564761993052217.44157726761887; Fri, 2 Aug 2019 09:06:33 -0700 (PDT) Received: from localhost ([::1]:36170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hta4c-0000B3-2Z for importer@patchew.org; Fri, 02 Aug 2019 12:06:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60573) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hta3F-0006qT-VE for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hta3E-000205-Ic for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:05 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:40519) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hta3E-0001yc-C2 for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:04 -0400 Received: by mail-wm1-x342.google.com with SMTP id v19so66859650wmj.5 for ; Fri, 02 Aug 2019 09:05:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o7sm66200171wmf.43.2019.08.02.09.05.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 09:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BfQH4lRAqpmkXsMJ0tZi39/pftehOKqOJC/urrgU2h8=; b=NUlf8tPNQjy00va2F2YESvdUaz1WmLfyN7kpPPQ9jKJL03hlqfuumq5zsCMhlxewvq +n8oSSuwlOcFoSpEmYrGfsFcyt+rDFHQcOr0Z+c0C8sg4bQ+PHaMEYAv4JFsMmzC/hCY LvPhmsxjxTYELls5vQWv/btPBbCmijNPnnJqijs+CI2P/GTtErKQGXxFFZKmimA29hhV TQQjIlGLgnpEP4cCnO0bhVe/N80KDqt0V064ctlHFX1TWrVrLHw7A5LycfdviySsso52 fZLUW+T8sjfEjjkjmCEv7lfJkMynGMdX5YeIOWOCbmI1iJA1XxN/ZhGJvHvW9gJWzryo kotg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BfQH4lRAqpmkXsMJ0tZi39/pftehOKqOJC/urrgU2h8=; b=ocx2aDf/AZcXvIg93242o5LeS2hiF/Hr3ErgYyZVaqJtomeaask5uRoOofL/LMRxus mnsrRG+w7XjF6O30TmRkrR/6/WuXJXC7sXi2mvowri5Ndmlry4i3MTP6FMDeXG9jtKJQ WxRbXe3ybHm+kjPnKPYZE92regv8k9k6+a9VAN4kfE1JP9Pky3q+plIM+iuLXVIZeQPX LgjjmfKCE1ddgFlnjbBwcCv8o9317xJJbrusCrDzAOt1z+J8ILE0p+mpivBHe93j9fMh 1l0S3cf/7ZbPvVdTMSlI/oKkWbK5BnYaTmA1rid+i+65YzC4dhMx/oHIHqo6FQKzBh4U xhfw== X-Gm-Message-State: APjAAAXiL040d0LwdUkTx991+V1mxRCYDUdytoVXuhs+S34PF6EKPTXQ z7/gfnbkEVRJ0QpYruHb/wybxcp8BBnxIA== X-Google-Smtp-Source: APXvYqyo129j5C7I6KevPiEjEFLy+Z5twKgGrrQcHxNawEJhnHKjI1wCl/qPh4bK/VYE+roeNxojEA== X-Received: by 2002:a1c:9a53:: with SMTP id c80mr4811460wme.173.1564761902450; Fri, 02 Aug 2019 09:05:02 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 2 Aug 2019 17:04:56 +0100 Message-Id: <20190802160458.25681-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802160458.25681-1-peter.maydell@linaro.org> References: <20190802160458.25681-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH 1/3] hw/mips/mips_jazz: Override do_transaction_failed hook X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The MIPS Jazz ('magnum' and 'pica61') boards have some code which overrides the CPU's do_unassigned_access hook, so they can intercept it and not raise exceptions on data accesses to invalid addresses, only for instruction fetches. We want to switch MIPS over to using the do_transaction_failed hook instead, so add an intercept for that as well, and make the board code install whichever hook the CPU is actually using. Once we've changed the CPU implementation we can remove the redundant code for the old hook. Note: I am suspicious that the behaviour as implemented here may not be what the hardware really does. It was added in commit 54e755588cf1e90f0b14 to restore the behaviour that was broken by commit c658b94f6e8c206c59d. But prior to commit c658b94f6e8c206c59d every MIPS board generated exceptions for instruction access to invalid addresses but not for data accesses; and other boards, notably Malta, were fixed by making all invalid accesses behave as reads-as-zero (see the call to empty_slot_init() in mips_malta_init()). Hardware that raises exceptions for instruction access and not data access seems to me to be an unlikely design, and it's possible that the right way to emulate this is to make the Jazz boards do what we did with Malta (or some variation of that). Nonetheless, since I don't have access to real hardware to test against I have taken the approach of "make QEMU continue to behave the same way it did before this commit". I have updated the comment to correct the parts that are no longer accurate and note that the hardware might behave differently. The test case for the need for the hook-hijacking is in https://bugs.launchpad.net/qemu/+bug/1245924 That BIOS will boot OK either with this overriding of both hooks, or with a simple "global memory region to ignore bad accesses of all types", so it doesn't provide evidence either way, unfortunately. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Herv=C3=A9 Poussineau --- hw/mips/mips_jazz.c | 54 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index fa8775d4284..c64b4c78809 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -123,6 +123,28 @@ static void mips_jazz_do_unassigned_access(CPUState *c= pu, hwaddr addr, (*real_do_unassigned_access)(cpu, addr, is_write, is_exec, opaque, siz= e); } =20 +static void (*real_do_transaction_failed)(CPUState *cpu, hwaddr physaddr, + vaddr addr, unsigned size, + MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, + uintptr_t retaddr); + +static void mips_jazz_do_transaction_failed(CPUState *cs, hwaddr physaddr, + vaddr addr, unsigned size, + MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, + uintptr_t retaddr) +{ + if (access_type !=3D MMU_INST_FETCH) { + /* ignore invalid access (ie do not raise exception) */ + return; + } + (*real_do_transaction_failed)(cs, physaddr, addr, size, access_type, + mmu_idx, attrs, response, retaddr); +} + static void mips_jazz_init(MachineState *machine, enum jazz_model_e jazz_model) { @@ -157,16 +179,32 @@ static void mips_jazz_init(MachineState *machine, env =3D &cpu->env; qemu_register_reset(main_cpu_reset, cpu); =20 - /* Chipset returns 0 in invalid reads and do not raise data exceptions. + /* + * Chipset returns 0 in invalid reads and do not raise data exceptions. * However, we can't simply add a global memory region to catch - * everything, as memory core directly call unassigned_mem_read/write - * on some invalid accesses, which call do_unassigned_access on the - * CPU, which raise an exception. - * Handle that case by hijacking the do_unassigned_access method on - * the CPU, and do not raise exceptions for data access. */ + * everything, as this would make all accesses including instruction + * accesses be ignored and not raise exceptions. + * So instead we hijack either the do_unassigned_access method or + * the do_transaction_failed method on the CPU, and do not raise excep= tions + * for data access. + * + * NOTE: this behaviour of raising exceptions for bad instruction + * fetches but not bad data accesses was added in commit 54e755588cf1e9 + * to restore behaviour broken by c658b94f6e8c206, but it is not clear + * whether the real hardware behaves this way. It is possible that + * real hardware ignores bad instruction fetches as well -- if so then + * we could replace this hijacking of CPU methods with a simple global + * memory region that catches all memory accesses, as we do on Malta. + */ cc =3D CPU_GET_CLASS(cpu); - real_do_unassigned_access =3D cc->do_unassigned_access; - cc->do_unassigned_access =3D mips_jazz_do_unassigned_access; + if (cc->do_unassigned_access) { + real_do_unassigned_access =3D cc->do_unassigned_access; + cc->do_unassigned_access =3D mips_jazz_do_unassigned_access; + } + if (cc->do_transaction_failed) { + real_do_transaction_failed =3D cc->do_transaction_failed; + cc->do_transaction_failed =3D mips_jazz_do_transaction_failed; + } =20 /* allocate RAM */ memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram", --=20 2.20.1 From nobody Mon Apr 29 00:52:14 2024 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564762069; cv=none; d=zoho.com; s=zohoarc; b=BX7wVn/qcxEeRtEDC5uc5FHL38vu7TsWZD0SxMa0cFjb+SPoSU4t1UwTGtN5F53oNEErSmLJoMMeVU+9anITmbp5Eh+JkU3t8TtYI+PljiOkJj2uooTucAyWeeelpDNCSNZeDOg1Dwoy+Amj4wkDxKsBh9GDbeS83YCFcQlEGh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564762069; 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=/Si04CZi+jPrI1hrdsqdiLuVY6itlYimxkl7cUi4ico=; b=gnhlW2zOgp8LQOcLrE7SAdMSsD0QQt2vGgVFfkb8sU56OK5bDtZO15694SBvwbxp+utqkt8Zh4GXvE5A/5Go5yY5jQkMbCdVI2ZgCA8P0gSXpbSojHJOVQ7oPFu5inXIrs+xTnMVOFZ2nGQSYmOoBl9Ed88gr/uQlEZcHqUts2g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564762069852659.6338326013365; Fri, 2 Aug 2019 09:07:49 -0700 (PDT) Received: from localhost ([::1]:36190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hta5s-0002Qb-RE for importer@patchew.org; Fri, 02 Aug 2019 12:07:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60585) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hta3H-0006qu-G6 for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hta3F-00024k-Ic for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:07 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:39042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hta3F-00020Q-BS for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:05 -0400 Received: by mail-wr1-x444.google.com with SMTP id x4so24556629wrt.6 for ; Fri, 02 Aug 2019 09:05:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o7sm66200171wmf.43.2019.08.02.09.05.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 09:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/Si04CZi+jPrI1hrdsqdiLuVY6itlYimxkl7cUi4ico=; b=WGKr7PSD52mgAK/eb/wMJYPIoWSJJECDPjLr634XMTcCFkbqZ8MJFRTHAQRYmIkyyz IE/+v/Hb87d0uIjEJo/3FbIBp8wYfFxVeqDUkc1zda8ExJrX0D27EvBQcjCesko/SlnY ENIqDQ0bkHpKK/3CiaM6eBSRFoWFjhOzT47STksAPlu08XKf4SW/wt5vqRhy4tKKF1nX jAdXriw+Qzz5sg499Z+rfe4L5NyqeM47kCW1El0zCJ15C8GOuAK/UGWbou3Tb+yQYdhJ GgVU9GE1eHryoapvorYGkWOxfDKYUn1f5p/o7ktg2fIo/NOsZt1kDaz1/Usj93r8adlc ysBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/Si04CZi+jPrI1hrdsqdiLuVY6itlYimxkl7cUi4ico=; b=cjActQfue150wzfQL//8nWjAqqKDmOqM2Y8xKmlGy31bo1GELo5wQUYhOisEui8wJ7 BNJAhtnWL/pASNOAzjlMEGhUX040pPzTMiLVgl7SadFHPdxEevfrfefF7syM4hJjiyGY aeQbl90gvQRT6r6tzCx0CjoEPdFWjko5YGPkS0lWJuaUB6tKh7p54TW7JixAgrpl1NbG UjltHgtVMzq5QqPfw+V6R5QZDSi/askxOG1aRn65J67p+yDyv6D3Xdz+lfgghCD1YSkz HvOfaBcXEldXJzZGymIupg5RWidlqGtDtotX5Dmsiv6h4b+O98JnMq2bBO2bs1banmU5 Yk8g== X-Gm-Message-State: APjAAAVclV1ekmK7ZwG/0U+qk8c6e1naksBDCQCIDFbkllPkgp78vHQ1 N+a4piXYtBBlT4l5KxDNt5YLZUpR8RsGnw== X-Google-Smtp-Source: APXvYqyTnue+ZR3YWHXE91hVIOGkHLsoXf5oYfCT8TtzIUJiDqZyGvEBUNoe3u2Eg8KDNRzlPyXReg== X-Received: by 2002:a5d:6583:: with SMTP id q3mr10467702wru.184.1564761904164; Fri, 02 Aug 2019 09:05:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 2 Aug 2019 17:04:57 +0100 Message-Id: <20190802160458.25681-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802160458.25681-1-peter.maydell@linaro.org> References: <20190802160458.25681-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH 2/3] target/mips: Switch to do_transaction_failed() hook X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Switch the MIPS target from the old unassigned_access hook to the new do_transaction_failed hook. Unlike the old hook, do_transaction_failed is only ever called from the TCG memory access paths, so there is no need for the "ignore this if we're using KVM" hack that we were previously using to work around the way unassigned_access was called for all kinds of memory accesses to unassigned physical addresses. The MIPS target does not ever do direct memory reads by physical address (via either ldl_phys etc or address_space_ldl etc), so the only memory accesses this affects are the 'normal' guest loads and stores, which will be handled by the new hook; their behaviour is unchanged. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Herv=C3=A9 Poussineau --- target/mips/internal.h | 8 +++++--- target/mips/cpu.c | 2 +- target/mips/op_helper.c | 24 ++++++++---------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/target/mips/internal.h b/target/mips/internal.h index b2b41a51ab4..26533bb937d 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -138,9 +138,11 @@ void r4k_helper_tlbinv(CPUMIPSState *env); void r4k_helper_tlbinvf(CPUMIPSState *env); void r4k_invalidate_tlb(CPUMIPSState *env, int idx, int use_extra); =20 -void mips_cpu_unassigned_access(CPUState *cpu, hwaddr addr, - bool is_write, bool is_exec, int unused, - unsigned size); +void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, + vaddr addr, unsigned size, + MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retadd= r); hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address, int rw); #endif diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 39eafafc5cd..a79badcb1a6 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -197,7 +197,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) cc->gdb_read_register =3D mips_cpu_gdb_read_register; cc->gdb_write_register =3D mips_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY - cc->do_unassigned_access =3D mips_cpu_unassigned_access; + cc->do_transaction_failed =3D mips_cpu_do_transaction_failed; cc->do_unaligned_access =3D mips_cpu_do_unaligned_access; cc->get_phys_page_debug =3D mips_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_mips_cpu; diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index 9e2e02f8586..65ff9f5b935 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -2666,27 +2666,19 @@ void mips_cpu_do_unaligned_access(CPUState *cs, vad= dr addr, do_raise_exception_err(env, excp, error_code, retaddr); } =20 -void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr, - bool is_write, bool is_exec, int unused, - unsigned size) +void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, + vaddr addr, unsigned size, + MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retadd= r) { MIPSCPU *cpu =3D MIPS_CPU(cs); CPUMIPSState *env =3D &cpu->env; =20 - /* - * Raising an exception with KVM enabled will crash because it won't b= e from - * the main execution loop so the longjmp won't have a matching setjmp. - * Until we can trigger a bus error exception through KVM lets just ig= nore - * the access. - */ - if (kvm_enabled()) { - return; - } - - if (is_exec) { - raise_exception(env, EXCP_IBE); + if (access_type =3D=3D MMU_INST_FETCH) { + do_raise_exception(env, EXCP_IBE, retaddr); } else { - raise_exception(env, EXCP_DBE); + do_raise_exception(env, EXCP_DBE, retaddr); } } #endif /* !CONFIG_USER_ONLY */ --=20 2.20.1 From nobody Mon Apr 29 00:52:14 2024 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1564762005; cv=none; d=zoho.com; s=zohoarc; b=chGWMMkxhuUURUW1gQ7Jzo3Q5s0pZChJaZIoXt4NeRWA0ZQWRXFXwcVXIJb3aG6ONVP4rm5F1tv5+Nxaivw0ViW1yrfwh9PXlwF0SldwRY4qBsk2b6O/fCudpgHHq8WxjeuoVwX6wISKw4aVS6dIML5FWRDbI2ce6IUri0W779g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564762005; 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=6pf+/Ei8SJThuyQtu04YRjgRwIND6kl09cbvvwUqAXg=; b=UN7MqUppC+Ngt7lug3ltS+H5evmpiXwoH38x6GfFU1gVWzaFe9WYGg/6Ut/NmUBSxPpwydBZ3pC8DC7nlotrcMiMoQ+f7s33j2DRhexfGsHjvnV4ezcqzabrcgF2Lq96bgZa3ZIG/rdZQmO4+02RQs0VDR8zatxMLfZVC4TN7f0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156476200509515.568332334808474; Fri, 2 Aug 2019 09:06:45 -0700 (PDT) Received: from localhost ([::1]:36172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hta4q-0000sq-6T for importer@patchew.org; Fri, 02 Aug 2019 12:06:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60596) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hta3I-0006rR-KL for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hta3H-00026c-Gd for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:08 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:33496) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hta3G-00025Z-D1 for qemu-devel@nongnu.org; Fri, 02 Aug 2019 12:05:07 -0400 Received: by mail-wm1-x341.google.com with SMTP id h19so1777819wme.0 for ; Fri, 02 Aug 2019 09:05:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o7sm66200171wmf.43.2019.08.02.09.05.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 09:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6pf+/Ei8SJThuyQtu04YRjgRwIND6kl09cbvvwUqAXg=; b=hiF8PgyrgiYpewNrug20sSSyPijR5kSUTda7tH4D9fzdife9gSXke30dSMEEIioPso cYpk6oGE/Kr+jwGwv4okaMNk7Ft4Bg9CcXhzJme5K8nCwv7nCYTlw1bcNO/OqVz0/oa5 lC34EFG97yFJGG712mQ5pxexybmOUH6vU2sx9KOCJrR0QG94bgeuiqdXOwCK0mXswAh7 iDPnvkqXCGDQZqdCfLnIyBg4XMN4PLohsh2/ODCQbE+SvIZR/oVxWi8qqJkwDwvqGnWf SeiGLOQXKxpnZJA4sxKRZ5FGjuxGMbz0/SPpNTxq/4u2N6yHVD/5EJuKnfsqOvZ3huow QVsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6pf+/Ei8SJThuyQtu04YRjgRwIND6kl09cbvvwUqAXg=; b=Hu1nw3Osy567LAdEpHxYcM9JOhgkwpE0/sEai2iz52I4kj+fDYtaWZ13nSS+q6ZcpH mg0pe56Sz9ai5NGYvETXTAHvkneqy1rkG/MPhOdgSCNdAvEZ2eOvvxYiiw25TN9ahsy1 qGxfDgRTTAt9ZjtSre0/a2ARO8xg3lns+FwRqq15UuF3WG0ZD7gZvlSIJlwm7+YgPeHy r/ROLZvnO9YZStd6qsNprEMHLL2Kk+53FFhDwlN9TGpf66Hf77R6XWziBi75ol5bfuo/ PRQgmt+7fbeQTcMh9CmFWCAxpf+h6ElX55fg8W2pObrRRITKSwd+slS09qhu5yT39sfv LXmQ== X-Gm-Message-State: APjAAAWYL8k/UBxGq2Xrjpylb1ktToREe6fIOkjCANiE7LD016AWZ3xs ZJlFs/sb6ohTOMfSpdKGeOsRI/SJcZ+f4g== X-Google-Smtp-Source: APXvYqyf5dpeOzKrQZAPP0Ue1CbEHTESCV8v+wXhhac8cluUsmLeN/DcUTuoSoqXtL2D5mM5USGpMA== X-Received: by 2002:a1c:4c1a:: with SMTP id z26mr5049177wmf.2.1564761905233; Fri, 02 Aug 2019 09:05:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 2 Aug 2019 17:04:58 +0100 Message-Id: <20190802160458.25681-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802160458.25681-1-peter.maydell@linaro.org> References: <20190802160458.25681-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH 3/3] hw/mips/mips_jazz: Remove no-longer-necessary override of do_unassigned_access X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Now that the MIPS CPU implementation uses the new do_transaction_failed hook, we can remove the old code that handled the do_unassigned_access hook. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Herv=C3=A9 Poussineau --- hw/mips/mips_jazz.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index c64b4c78809..540943932fd 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -111,18 +111,6 @@ static const MemoryRegionOps dma_dummy_ops =3D { #define MAGNUM_BIOS_SIZE_MAX 0x7e000 #define MAGNUM_BIOS_SIZE (BIOS_SIZE < MAGNUM_BIOS_SIZE_MAX ? BIOS_SIZE : M= AGNUM_BIOS_SIZE_MAX) =20 -static CPUUnassignedAccess real_do_unassigned_access; -static void mips_jazz_do_unassigned_access(CPUState *cpu, hwaddr addr, - bool is_write, bool is_exec, - int opaque, unsigned size) -{ - if (!is_exec) { - /* ignore invalid access (ie do not raise exception) */ - return; - } - (*real_do_unassigned_access)(cpu, addr, is_write, is_exec, opaque, siz= e); -} - static void (*real_do_transaction_failed)(CPUState *cpu, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, @@ -184,9 +172,8 @@ static void mips_jazz_init(MachineState *machine, * However, we can't simply add a global memory region to catch * everything, as this would make all accesses including instruction * accesses be ignored and not raise exceptions. - * So instead we hijack either the do_unassigned_access method or - * the do_transaction_failed method on the CPU, and do not raise excep= tions - * for data access. + * So instead we hijack the do_transaction_failed method on the CPU, a= nd + * do not raise exceptions for data access. * * NOTE: this behaviour of raising exceptions for bad instruction * fetches but not bad data accesses was added in commit 54e755588cf1e9 @@ -197,14 +184,8 @@ static void mips_jazz_init(MachineState *machine, * memory region that catches all memory accesses, as we do on Malta. */ cc =3D CPU_GET_CLASS(cpu); - if (cc->do_unassigned_access) { - real_do_unassigned_access =3D cc->do_unassigned_access; - cc->do_unassigned_access =3D mips_jazz_do_unassigned_access; - } - if (cc->do_transaction_failed) { - real_do_transaction_failed =3D cc->do_transaction_failed; - cc->do_transaction_failed =3D mips_jazz_do_transaction_failed; - } + real_do_transaction_failed =3D cc->do_transaction_failed; + cc->do_transaction_failed =3D mips_jazz_do_transaction_failed; =20 /* allocate RAM */ memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram", --=20 2.20.1