From patchwork Wed Mar 3 01:39:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 392032 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp4739720jap; Tue, 2 Mar 2021 17:39:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8NGBWJkIM2WE2bItUeGpIioCLfxY5JIbBoofF7mLYeq34EQZWR0DtkJHKwnEU+T+rxY9r X-Received: by 2002:a9d:784b:: with SMTP id c11mr20080671otm.88.1614735598139; Tue, 02 Mar 2021 17:39:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614735598; cv=none; d=google.com; s=arc-20160816; b=ZLN/T1PQ7aWl5oEXR88lvbnA4t3JLUuoV7lY9caCu76aOjNVsPy3UByQtOS4DlVjFS Kw7VDxD9STZi5Bt/PB1hhOTZNEC0UhKPJJ+Q439BGtfURhvEvs3EjECgnN+XZypAXHQf H9sHPYVPGvgFh8Du+RKie5/czA8x6Wn7Arwiel0qMcWu4xFGMan4ZdME1jSuvcy89XXV RDTYSFocs9hIn8hGmsl4/SUE7WSDmFHh7uzogpnHyEcQQiyRgGwbQY/8ZF2YHElzHkgC LZByFj2ha8+RSMvJOuqh2SMF2WbwJM0mc/2KMkBDJ0Df0HCKMOPXjIwJJsbiKHCbGO/8 HUVQ== 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:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=eZ97uMunfAGCnWu1sil3Tpn+4Vo2orqUvsENooULL8c=; b=s19sqbfMVSF5MpltGPVwp43C3TxR9YMhE5ko44N9yQzWUzVmgjdyVUsYlnx9t72z8A YhiCHt8Yk5RB9HsPhQTwURqEmRL3/f2KN6d1+N+UEizViALdRbMZAy0xBbQ4zkKzx0uu vxpX5GoSQ//U4fRluM3XxWg99pcijW1TlLKcBPGz+pqdiR7qtgI0aEx8SdaW2q7daVaT soL6XVJvsuipV5BhL70eLc1bE3UlpeHKGmbSByep/pzMa4veKyACVbLSAEKQOZt4k4Op IE3Y+FDtI+y3Ycv2j2H/il5iRLDjzWlFbC7sTlQBILkXNAesuPUGnh/gIm4Y0SYpf+n9 6Gdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Woxe402H; 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=fail (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 d26si16336116ood.10.2021.03.02.17.39.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Mar 2021 17:39:58 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=Woxe402H; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHGUX-0008CK-HU for patch@linaro.org; Tue, 02 Mar 2021 20:39:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHGTw-0008C7-GI for qemu-devel@nongnu.org; Tue, 02 Mar 2021 20:39:20 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:37501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHGTu-0005a2-N9 for qemu-devel@nongnu.org; Tue, 02 Mar 2021 20:39:20 -0500 Received: by mail-pl1-x630.google.com with SMTP id p5so13136659plo.4 for ; Tue, 02 Mar 2021 17:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eZ97uMunfAGCnWu1sil3Tpn+4Vo2orqUvsENooULL8c=; b=Woxe402HfL+SD+GkSbIDaf1eggbY+Nzinaft4HjoEd4nhdt+b53UWXxILocoAsj6jL +j38KHYvlLxczFat59ZLwl7E7jFvT2L+X6MQFrRw1gZ/VZCypBzcmM4CydHV7g3WnChb weQIfYwb50KjOQti869exStMVnG6HL0bXijdpA05+bRp5CodzQw/eKQXz502eEI7+6gK ee/0zbn5p/OB+5x0rttBwLEFpL2IrgKKWi6osvmr1nee+dJG00vD9kQ7d14oKf3DF9O4 xhvc5hyYpJ+5Fg6JzZPxjIkgVPRtJuaT8naafiH/1S2yA1ObGaNoMjaUK1SGpZGw0Ir6 +ZiA== 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:mime-version :content-transfer-encoding; bh=eZ97uMunfAGCnWu1sil3Tpn+4Vo2orqUvsENooULL8c=; b=ARhTMrrY4yqHDDVtgub9/Me9aFTloiIdx97WWdMgideDPiHDKYkO+U59wECsUAma6D Uu2100xOiFMaN48kuZSqK0Rm3r0MjyiM8gdcKpWRNRFv70CyVbq+uHyS0l0Lcq45mvq0 pntT7+Rx+BQCX64d0ANZ4ZcRfPrrK6dtZjQ6uRvZa5kr6No4+9wPW3prtoKr7kvstnE2 ZHh+SIqAvUrjgVDO8RTxMQouptcQrvs4AvbONZYLhaTIVrFjgQ6nV5GnukI4oMgRStgj DtP072NdO2rEMvcrcB/xuwn2cG2STnjn2k2i7dzhdqaY8B3wVZ2K7ILXu/Y5cE6/lRIm frdg== X-Gm-Message-State: AOAM531tE9q7jIIt8Ranx1rFbrx0tJDMDyteN8+gZKPMguBDz+4M4U1e G0VfbtBwsTNa4gEKq/8JYuXm643YFP6Hwg== X-Received: by 2002:a17:90a:2ec6:: with SMTP id h6mr7177633pjs.103.1614735556729; Tue, 02 Mar 2021 17:39:16 -0800 (PST) Received: from localhost.localdomain (174-21-84-25.tukw.qwest.net. [174.21.84.25]) by smtp.gmail.com with ESMTPSA id q128sm22643671pfb.51.2021.03.02.17.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 17:39:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2] target/s390x: Implement the MVPG condition-code-option bit Date: Tue, 2 Mar 2021 17:39:15 -0800 Message-Id: <20210303013915.3122076-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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: qemu-s390x@nongnu.org, Thomas Huth , David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If the CCO bit is set, MVPG should not generate an exception but report page translation faults via a CC code. Create a new helper, access_prepare_nf, which can use probe_access_flags in non-faulting mode. Cc: David Hildenbrand Reported-by: Thomas Huth Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 76 +++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 23 deletions(-) -- 2.25.1 diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 25cfede806..9e359b0d19 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -130,28 +130,51 @@ typedef struct S390Access { int mmu_idx; } S390Access; +static bool access_prepare_nf(S390Access *access, CPUS390XState *env, + bool nofault, vaddr vaddr1, int size, + MMUAccessType access_type, + int mmu_idx, uintptr_t ra) +{ + void *haddr1, *haddr2 = NULL; + int size1, size2; + vaddr vaddr2 = 0; + bool ok; + + g_assert(size > 0 && size <= 4096); + + size1 = MIN(size, -(vaddr1 | TARGET_PAGE_MASK)), + size2 = size - size1; + + ok = probe_access_flags(env, vaddr1, access_type, mmu_idx, + nofault, &haddr1, ra); + if (likely(ok) && unlikely(size2)) { + /* The access crosses page boundaries. */ + vaddr2 = wrap_address(env, vaddr1 + size1); + ok = probe_access_flags(env, vaddr2, access_type, mmu_idx, + nofault, &haddr2, ra); + } + + *access = (S390Access) { + .vaddr1 = vaddr1, + .vaddr2 = vaddr2, + .haddr1 = haddr1, + .haddr2 = haddr2, + .size1 = size1, + .size2 = size2, + .mmu_idx = mmu_idx + }; + return ok; +} + static S390Access access_prepare(CPUS390XState *env, vaddr vaddr, int size, MMUAccessType access_type, int mmu_idx, uintptr_t ra) { - S390Access access = { - .vaddr1 = vaddr, - .size1 = MIN(size, -(vaddr | TARGET_PAGE_MASK)), - .mmu_idx = mmu_idx, - }; - - g_assert(size > 0 && size <= 4096); - access.haddr1 = probe_access(env, access.vaddr1, access.size1, access_type, - mmu_idx, ra); - - if (unlikely(access.size1 != size)) { - /* The access crosses page boundaries. */ - access.vaddr2 = wrap_address(env, vaddr + access.size1); - access.size2 = size - access.size1; - access.haddr2 = probe_access(env, access.vaddr2, access.size2, - access_type, mmu_idx, ra); - } - return access; + S390Access ret; + bool ok = access_prepare_nf(&ret, env, false, vaddr, size, + access_type, mmu_idx, ra); + g_assert(ok); + return ret; } /* Helper to handle memset on a single page. */ @@ -845,8 +868,10 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64_t r2) const int mmu_idx = cpu_mmu_index(env, false); const bool f = extract64(r0, 11, 1); const bool s = extract64(r0, 10, 1); + const bool cco = extract64(r0, 8, 1); uintptr_t ra = GETPC(); S390Access srca, desta; + bool ok; if ((f && s) || extract64(r0, 12, 4)) { tcg_s390_program_interrupt(env, PGM_SPECIFICATION, GETPC()); @@ -858,13 +883,18 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64_t r2) /* * TODO: * - Access key handling - * - CC-option with surpression of page-translation exceptions * - Store r1/r2 register identifiers at real location 162 */ - srca = access_prepare(env, r2, TARGET_PAGE_SIZE, MMU_DATA_LOAD, mmu_idx, - ra); - desta = access_prepare(env, r1, TARGET_PAGE_SIZE, MMU_DATA_STORE, mmu_idx, - ra); + ok = access_prepare_nf(&srca, env, cco, r2, TARGET_PAGE_SIZE, + MMU_DATA_LOAD, mmu_idx, ra); + if (!ok) { + return 2; + } + ok = access_prepare_nf(&desta, env, cco, r1, TARGET_PAGE_SIZE, + MMU_DATA_STORE, mmu_idx, ra); + if (!ok) { + return 1; + } access_memmove(env, &desta, &srca, ra); return 0; /* data moved */ }