From patchwork Tue Oct 1 17:16:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174907 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp8851236ill; Tue, 1 Oct 2019 10:28:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCP9SG2k+ixQz9Gnh5B1phc2zsVUt3Zc60UrZE97JuQ9JsaFA2mlit2uNxtOoIP8A8NICM X-Received: by 2002:a17:906:493:: with SMTP id f19mr5219042eja.285.1569950895774; Tue, 01 Oct 2019 10:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569950895; cv=none; d=google.com; s=arc-20160816; b=lbdT18C8kxp7R5VXTF1PzZArixWNpQp8ylDoJ5PPxZCM4zsfdoomJ6XLnOScx6JPVO zyvuuG9kBZP0D40fgzSYQrFjCxltOsyMuUvK3IU9kV3X1EYYe5bKtcmPhlUynkS3qbeO vLbeWW3T6r6kOiM/C1ZUUW4wz8OLXt2n38Mj4XIWAI+XGIODQVirlXWh9CFcT1+Bh8h7 NUNYiciu/pVuvwMz42mbwb9g3k+sxf5vjNN1CAZinWQK2gM2w2u7bPhgQFJkGqg7xAAo wMDGZ/qh/ub6ZlpJfSVbqnu15uwxWbGjMJ+VYLmg73YPe35DxgDbsod1Q/Ee85PX3fvl Pvjw== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=qV5DRSUK9uxLr8VUlGB8IPLCjYhHZMF32okiY81/uHY=; b=yO/vLKYaQSPY9o4DsELm+W1s/fr+4iLcM9DzeMiQTdb26zVdQ7x/B4OtevJVejrZTM uD4JQe/H8MDDuZZ/zibXo8YMgcnuNE/wVrP4GLgT8avN//ehZJOSskS6+qGr+PNJJROL Bl0t3ODJ7zwwp+fyf5Lllwn6GG1b8ob48kyAzmCn+fMD+OWF3n1aKGcx51X5jB1I27wG ZSSO2rjML3VCw8Tf5vrHSEjIEZmnc0I9qRxqKUQnDOHDqSGktPw3TfnpXRNLV/5mttOc RRUmrprdEmeAYUZheU3a0njJKtE0QzMhXhgKq5DyrIcrQ+Uwd7kJL4OdPR2e71MKwGwU jRkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sfohzBHO; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h14si9741588edb.425.2019.10.01.10.28.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Oct 2019 10:28:15 -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; dkim=pass header.i=@linaro.org header.s=google header.b=sfohzBHO; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFLwc-0004tp-LR for patch@linaro.org; Tue, 01 Oct 2019 13:28:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32868) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFLlH-0001cm-RX for qemu-devel@nongnu.org; Tue, 01 Oct 2019 13:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iFLlG-0005YI-Mt for qemu-devel@nongnu.org; Tue, 01 Oct 2019 13:16:31 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:34348) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iFLlG-0005Xw-Hg for qemu-devel@nongnu.org; Tue, 01 Oct 2019 13:16:30 -0400 Received: by mail-pg1-x542.google.com with SMTP id y35so10119373pgl.1 for ; Tue, 01 Oct 2019 10:16:30 -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; bh=qV5DRSUK9uxLr8VUlGB8IPLCjYhHZMF32okiY81/uHY=; b=sfohzBHOfz0OtcjcoVM3eEN2UWS/MQfxBDhy+XwtpM/X1TS4xXyM1fv8yfRp883mxA O57Xr9tC6hGZcqCm5uIK1ra4vG5VWcHRhNJjBb9S3vwGiJgwnhcQfBF/bAU0gMOpxyqy lhCaOgya7pBK+ew6ruys5zeuwSnhOQJKrLPtJaUQmrcn4UZTznUY3PqYUrdp2HLskmw2 q7rngMc41RR1BN8orbuVr67Hy0HuQ/NJn/eBRB61Mfc8mn1JYEgyRKImkLa1uz8scdkw wSHDqpQmlDOBtaS07Wl0mWH6HgjAHXZSH0mFttQL2CzAqWEQhY9/NTiR8y67qr2FPCVz gjeA== 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; bh=qV5DRSUK9uxLr8VUlGB8IPLCjYhHZMF32okiY81/uHY=; b=Hh/IyGfKXoYJuWL31ohZwV3q3Rhe8d4Hy4IhqUG9JrYDOQ2hiFk6LQLWdC/rOhCGfQ THTL7MEHZX5NLbg6s79U8kNpX77L7xDd1Yzr0wVbXqXGKgTkr058bxHzOxnhoHYBu3sy PXYxQGZhSPeok8223XjEUbZbKyqIytTVHPSf8KbZJ73EOOz1pkQze3hJLkhWzRc/A5tc Q15DuP0tjG8fyhgtmnXjDQEnOEARqHRHQ488I9W9Uikie9MhPfgpyWXg8lgdN6lX7B99 +VkQ4CTZ4BKQc5XZkf/d/lMjwmxWdZjcG/8I7ucLx/6dwZGiIkgrWoMhmjCsV+HQtQsR k1lw== X-Gm-Message-State: APjAAAXATKYJ9jLUjkqjZfAku2VLoiO6+ehL9GtqfiUVGmhi7/bMjm1G ncc5K+aV5WqG6103HRvLDZpvB0GnTXI= X-Received: by 2002:a17:90a:1b46:: with SMTP id q64mr6780639pjq.97.1569950188996; Tue, 01 Oct 2019 10:16:28 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id w7sm2863568pjn.1.2019.10.01.10.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 10:16:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 10/18] target/s390x: Return exception from translate_pages Date: Tue, 1 Oct 2019 10:16:06 -0700 Message-Id: <20191001171614.8405-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191001171614.8405-1-richard.henderson@linaro.org> References: <20191001171614.8405-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 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: david@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not raise the exception directly within translate_pages, but pass it back so that caller may do so. Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/mmu_helper.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c index 001d0a9c8a..869debd30a 100644 --- a/target/s390x/mmu_helper.c +++ b/target/s390x/mmu_helper.c @@ -451,25 +451,22 @@ nodat: * the MEMOP interface. */ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages, - target_ulong *pages, bool is_write) + target_ulong *pages, bool is_write, uint64_t *tec) { uint64_t asc = cpu->env.psw.mask & PSW_MASK_ASC; CPUS390XState *env = &cpu->env; int ret, i, pflags; for (i = 0; i < nr_pages; i++) { - uint64_t tec; - - ret = mmu_translate(env, addr, is_write, asc, &pages[i], &pflags, &tec); + ret = mmu_translate(env, addr, is_write, asc, &pages[i], &pflags, tec); if (ret) { - trigger_access_exception(env, ret, ILEN_AUTO, tec); - return -EFAULT; + return ret; } if (!address_space_access_valid(&address_space_memory, pages[i], TARGET_PAGE_SIZE, is_write, MEMTXATTRS_UNSPECIFIED)) { - trigger_access_exception(env, PGM_ADDRESSING, ILEN_AUTO, 0); - return -EFAULT; + *tec = 0; /* unused */ + return PGM_ADDRESSING; } addr += TARGET_PAGE_SIZE; } @@ -497,6 +494,7 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf, { int currlen, nr_pages, i; target_ulong *pages; + uint64_t tec; int ret; if (kvm_enabled()) { @@ -510,8 +508,10 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf, + 1; pages = g_malloc(nr_pages * sizeof(*pages)); - ret = translate_pages(cpu, laddr, nr_pages, pages, is_write); - if (ret == 0 && hostbuf != NULL) { + ret = translate_pages(cpu, laddr, nr_pages, pages, is_write, &tec); + if (ret) { + trigger_access_exception(&cpu->env, ret, ILEN_AUTO, tec); + } else if (hostbuf != NULL) { /* Copy data by stepping through the area page by page */ for (i = 0; i < nr_pages; i++) { currlen = MIN(len, TARGET_PAGE_SIZE - (laddr % TARGET_PAGE_SIZE));