From patchwork Mon Jan 9 20:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640699 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2341532pvb; Mon, 9 Jan 2023 12:25:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXEWKRWA3L6Oz4OH3EfqC4SxHE5uFy6uBR8/5z/Q84HQZam8a5PhOvICr1QMpTnmUL3E4z X-Received: by 2002:ac8:12c9:0:b0:3ab:5dc7:6be6 with SMTP id b9-20020ac812c9000000b003ab5dc76be6mr90384278qtj.39.1673295950873; Mon, 09 Jan 2023 12:25:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295950; cv=none; d=google.com; s=arc-20160816; b=O6nFPk6qK8Gs31Tq0L7AqmZv07P1LgnmqEWybY3UIhtMRHwn8b4/7l8ifR8h8zEkex zzQHE768IMc+eEwcl5qcwUBGTGtvR55NuFS68XPrJ9NVUIBCk1enoQXSqM+aEc8UF7Qa j1YsrehurmvRvSxQctYpHG7/lDXP6xI35hxx3WomQYFt3X0KTnGl76sxT53f0wRkSxoA IizMZo41bhJ1hqPPtD8TwWG8P7skExnuuuvJzBZFx/YZ5Tri/KpHkW3XTLzi+asnKH8d Kly+E9aM9fSzF89zzu2hGMMquzPUtbtuaaWYv70I2YyQNzZ7Aswr9Rm3BNQLH+amCmuz ydjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8qzET9c8q9s+vZ1TgifLLKnu2IuZqas7ApRIvzu8fJ8=; b=GC7ti58uyAQNS2X2P1v6LJwfzKH5T8KvRBbw501rw77wf55CGL2KXXmn/QLrHaMH3l h+udqx03jEl/Y9xdiBcsPF3IKRjXHvnS6TAyDFBkNHCtk56jjuIILeogiaXto16R4jlS yfOX0xC5qx6n0Sit7gy3J92DduoEt5Y0OcfB750qokFWB2ywfKorlVolW50jCvsbSKQr Me1gfPkWOdRzGgABIlfbTjmWieNE9crI9//OfeJONx2aU5Kzxv2oOR0SZuSQM8JKdvr1 WHIVgorRbjSMAPBhBCQxJ4Fh/7ZwZgfXNf1q/Hef4qt/ZYaBTZNwgGT1NopoMtzGW2bW UFwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NJ32uywq; 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 cf14-20020a05622a400e00b0039cf8f83b44si5164942qtb.391.2023.01.09.12.25.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 12:25:50 -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=pass header.i=@linaro.org header.s=google header.b=NJ32uywq; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEybq-00054j-HJ; Mon, 09 Jan 2023 15:19:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEybm-00051T-Un for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:03 -0500 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEybk-00052k-TQ for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:02 -0500 Received: by mail-pg1-x531.google.com with SMTP id 141so6720505pgc.0 for ; Mon, 09 Jan 2023 12:19:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8qzET9c8q9s+vZ1TgifLLKnu2IuZqas7ApRIvzu8fJ8=; b=NJ32uywqwon4xkfws9mlmpDqIbQ2f7C5g/bLBCUcQKoinmfoJyDBkzUEYwPNXj44sG Ep70M2dYtmebcHonaxoCAP8/XsSVZMzqJbeLfRjWIIVToTClfotHnzbhcrz8EJfuN1Wv nGOB8BxsrZTBOgbfDDETta20AKJUT/gCOyKQPPcdaaD51ELspFpA5EU3j3ssQuXjoend ljJPXnKuDGt7WuVlCqYlsns0B6yzAtOJKOQDTLq4fVs6dVSXLW+HiiSZqZzajhBc2LBk 2UJ/lAfvnjGEmQUaIdv950qW7tmhsJal6e/XuI/JhtXv6VGEfJqC0G8avY35n2TfBsQY LVmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8qzET9c8q9s+vZ1TgifLLKnu2IuZqas7ApRIvzu8fJ8=; b=4lBmCBAJsTg45jbxwcGc2lIOqFMKIIXmBpIEZw33ijZoLmU1iG3j2fZJv0YRPWRuf4 v9cMyHwxrECB/X0GM4uBUOGSXi4Q6RHZvCtaqyfTStivqKldWaGAsLQHrOy2bHCbLj/4 YmhdSduoBZJdCE9/A2bavaRHMoCm8/ICBv3XGfl+b2QWWS1+jYRv+BPox0Y5jaBcDrkD Re9OnA3fdyBy1+/VfLIgPObYq+LZiwzCEIBeABDOJdGIvMXYhKmRsNGU2LFQmA6K1Wpv pIUt50fVyYmaSbsDZlFz7tSIE4pu3dhRzAo/uwuGVrRowMk3qsNqWDkyvu2e98V2JPkm 7sxg== X-Gm-Message-State: AFqh2kpKyeXSSc5IpqLURmkGZiepVtuMSLtCRPg+BgYxCoq4uF1gih1F +HInUqtf4+We8MT60ydDIhUSzqO4xDmPG6dg X-Received: by 2002:aa7:9254:0:b0:572:6e9b:9f9e with SMTP id 20-20020aa79254000000b005726e9b9f9emr68261557pfp.19.1673295539155; Mon, 09 Jan 2023 12:18:59 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:158e:facf:7a46:ba9f]) by smtp.gmail.com with ESMTPSA id c132-20020a621c8a000000b00589a7824703sm1470972pfc.194.2023.01.09.12.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 12:18:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: david@redhat.com Subject: [PATCH 1/7] target/s390x: Fix s390_probe_access for user-only Date: Mon, 9 Jan 2023 12:18:50 -0800 Message-Id: <20230109201856.3916639-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109201856.3916639-1-richard.henderson@linaro.org> References: <20230109201856.3916639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In db9aab5783a2 we broke the contract of s390_probe_access, in that it no longer returned an exception code, nor set __excp_addr. Fix both. Reported-by: David Hildenbrand Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- target/s390x/tcg/mem_helper.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index cb82cd1c1d..5c0a7b1961 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -138,23 +138,27 @@ typedef struct S390Access { * For !CONFIG_USER_ONLY, the TEC is stored stored to env->tlb_fill_tec. * For CONFIG_USER_ONLY, the faulting address is stored to env->__excp_addr. */ -static int s390_probe_access(CPUArchState *env, target_ulong addr, int size, - MMUAccessType access_type, int mmu_idx, - bool nonfault, void **phost, uintptr_t ra) +static inline int s390_probe_access(CPUArchState *env, target_ulong addr, + int size, MMUAccessType access_type, + int mmu_idx, bool nonfault, + void **phost, uintptr_t ra) { -#if defined(CONFIG_USER_ONLY) - return probe_access_flags(env, addr, access_type, mmu_idx, - nonfault, phost, ra); -#else - int flags; + int flags = probe_access_flags(env, addr, access_type, mmu_idx, + nonfault, phost, ra); - env->tlb_fill_exc = 0; - flags = probe_access_flags(env, addr, access_type, mmu_idx, nonfault, phost, - ra); - if (env->tlb_fill_exc) { + if (unlikely(flags & TLB_INVALID_MASK)) { + assert(!nonfault); +#ifdef CONFIG_USER_ONLY + /* Address is in TEC in system mode; see s390_cpu_record_sigsegv. */ + env->__excp_addr = addr & TARGET_PAGE_MASK; + return (page_get_flags(addr) & PAGE_VALID + ? PGM_PROTECTION : PGM_ADDRESSING); +#else return env->tlb_fill_exc; +#endif } +#ifndef CONFIG_USER_ONLY if (unlikely(flags & TLB_WATCHPOINT)) { /* S390 does not presently use transaction attributes. */ cpu_check_watchpoint(env_cpu(env), addr, size, @@ -162,8 +166,9 @@ static int s390_probe_access(CPUArchState *env, target_ulong addr, int size, (access_type == MMU_DATA_STORE ? BP_MEM_WRITE : BP_MEM_READ), ra); } - return 0; #endif + + return 0; } static int access_prepare_nf(S390Access *access, CPUS390XState *env, From patchwork Mon Jan 9 20:18:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640697 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2341359pvb; Mon, 9 Jan 2023 12:25:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXskgZ2cjEjKvA4ssR3ayJSqlWXLq2YkUX8mBcK400d4iXjzQ+YZ03pl5zjr9rW3HsGEwhop X-Received: by 2002:a0c:eac7:0:b0:531:913e:3ba7 with SMTP id y7-20020a0ceac7000000b00531913e3ba7mr64378236qvp.14.1673295930524; Mon, 09 Jan 2023 12:25:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295930; cv=none; d=google.com; s=arc-20160816; b=gkncwyZTddfrGvJ3AWQh1RKdP01SwtbXrVwX3U4ZG3V3yMDF0AnuT/k5LZ0uP8uhmp Z6fP08fHOwWmvJ/YAiJ52i2NKWHU1f2I5asyKQJMtMK0cvzByG/vYuQw8vK1VovbvJE0 Su/A48jHI2OEfCb329e788w0Eaxt7gDgX12F5J1KfjMGLtujJWohZWCKV1xn2rJ1WynA 9nP9fn/LkaNHskLDF2dj69fItPOZujgaskJeGD7+S5pWeYJ0w3S5JA3MB8ff7bXnYw7R JymQDnunsZ9jIBTJkkmaWmr9fLBbNweFg/tRg+0vYWEzUICq7HoEKRg40qPvbrMtMaNb XWUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6Vb74LtWwc21gHPOHl2LL8p9rDUC+c0bSduX6H/J5KQ=; b=bCgJkl71gnyhRYc1R7eS2KjbiMl34mwH1GWsyIGv5mANXEGPkqJyXBf86YlQ/qkQ0p PvYVeVRiefYa8ZouUhtGowEUH1BkmKqv7wpN78uvRy5EXCPyvTtWmPD5EbSiEwaQVwvA TzJHX3xJ1qCJKD2OO7Uxx1sFHgcMZizBkSF346ES6C9Lo6d8eUpcnwQ7wsdW/ZqAXPdd kpV5nDTO6LCrHTYAmG97rzRE5UeEf1WxZIzjClNRUlZlCb+MXmHx7hCFp+2t62AC4Zii bZ94HzXRh8v/Zz7BgpIDDhxDKZv0HkyNA2dI5XtqzZEAFnoqLXDrDiVr/bDNd1vmt7tP KPXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YobFzlTr; 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 ke21-20020a056214301500b005322979e148si3010213qvb.52.2023.01.09.12.25.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 12:25:30 -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=pass header.i=@linaro.org header.s=google header.b=YobFzlTr; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEybq-00054D-81; Mon, 09 Jan 2023 15:19:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEybo-00051u-EP for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:04 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEybl-000532-QV for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:04 -0500 Received: by mail-pf1-x431.google.com with SMTP id 20so1660530pfu.13 for ; Mon, 09 Jan 2023 12:19:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Vb74LtWwc21gHPOHl2LL8p9rDUC+c0bSduX6H/J5KQ=; b=YobFzlTrfQ6TGZV77IeqPPQy/04knVimR1S1P/dgR/ZaRAUVRhPL1Zn+NyC0Q7a8li gVHRJozwD5n5aYnu0D4izKELF3xr3AGG5BqUD4L1ARisKgcRdt8K80SJN87vtMW9Y/zX xSx3Jf7oo0arL/A58Up0FZ8D01CyGYAtK8XPROoZ1O7OhZioM8lnIlbN4GlBxH5+6+3s zg6am9kiI4vcGIluaMtMoallA4Q+GgwiCv8XrqtdEolrI8Wmdd5jsW31x7990j1ICLAe 6jjUALnfp/jKCzuz8qWUdwEkJEZKs5s3Ziq7T2nMCRRoCg6m6dmwEdTH/XmmbgN/3WXH 9Nuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Vb74LtWwc21gHPOHl2LL8p9rDUC+c0bSduX6H/J5KQ=; b=rS/94mkOyjbOpya6TUhh53EpCFuQTwWg6plVVLsEN33fIM95IkeAHJWeN4SolZzJIc UD3i3DbqW1Ary2VNIV2gNvdftQbCM+ILf5YV1QsX6h9r6vV9k2CIHYnds2UdqSrNY/0b SDWTGR2IDFzRS0oa6ozSS+iwOuAZ8rbGh1Kngh5wjbKlumVujie/YXXutn0BFsIhgQhF FrzpeqAzQOprHNVUsD2FbpYnFymqjS8dr3m+G4KcG+lIcuPfxZ+EkZ7tjqJ+Dq0/z/YM Hmb2F6HV5Rt4uj8ObJVylh40w3TrA/IDWXs5dqwZcmMYn2tvk8abycpWVSlDmHySo8ge zoMw== X-Gm-Message-State: AFqh2koybGvlbic3dyRbce9zGIFD03Q7jSa3aqzBoGSk9a4ACQ5da3wF fpQIMOeMTZOvq7SjaEn7lNK0blbFh+d/LnMC X-Received: by 2002:a05:6a00:f0e:b0:587:749c:c0dc with SMTP id cr14-20020a056a000f0e00b00587749cc0dcmr6641478pfb.25.1673295540111; Mon, 09 Jan 2023 12:19:00 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:158e:facf:7a46:ba9f]) by smtp.gmail.com with ESMTPSA id c132-20020a621c8a000000b00589a7824703sm1470972pfc.194.2023.01.09.12.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 12:18:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: david@redhat.com Subject: [PATCH 2/7] target/s390x: Pass S390Access pointer into access_prepare Date: Mon, 9 Jan 2023 12:18:51 -0800 Message-Id: <20230109201856.3916639-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109201856.3916639-1-richard.henderson@linaro.org> References: <20230109201856.3916639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Passing a pointer from the caller down to access_prepare_nf eliminates a structure copy. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- target/s390x/tcg/mem_helper.c | 100 +++++++++++++++++----------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 5c0a7b1961..6a50189ef0 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -212,15 +212,14 @@ static int access_prepare_nf(S390Access *access, CPUS390XState *env, return 0; } -static S390Access access_prepare(CPUS390XState *env, vaddr vaddr, int size, - MMUAccessType access_type, int mmu_idx, - uintptr_t ra) +static inline void access_prepare(S390Access *ret, CPUS390XState *env, + vaddr vaddr, int size, + MMUAccessType access_type, int mmu_idx, + uintptr_t ra) { - S390Access ret; - int exc = access_prepare_nf(&ret, env, false, vaddr, size, + int exc = access_prepare_nf(ret, env, false, vaddr, size, access_type, mmu_idx, ra); assert(!exc); - return ret; } /* Helper to handle memset on a single page. */ @@ -412,9 +411,9 @@ static uint32_t do_helper_nc(CPUS390XState *env, uint32_t l, uint64_t dest, /* NC always processes one more byte than specified - maximum is 256 */ l++; - srca1 = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); - srca2 = access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); for (i = 0; i < l; i++) { const uint8_t x = access_get_byte(env, &srca1, i, ra) & access_get_byte(env, &srca2, i, ra); @@ -446,9 +445,9 @@ static uint32_t do_helper_xc(CPUS390XState *env, uint32_t l, uint64_t dest, /* XC always processes one more byte than specified - maximum is 256 */ l++; - srca1 = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); - srca2 = access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); /* xor with itself is the same as memset(0) */ if (src == dest) { @@ -487,9 +486,9 @@ static uint32_t do_helper_oc(CPUS390XState *env, uint32_t l, uint64_t dest, /* OC always processes one more byte than specified - maximum is 256 */ l++; - srca1 = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); - srca2 = access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); for (i = 0; i < l; i++) { const uint8_t x = access_get_byte(env, &srca1, i, ra) | access_get_byte(env, &srca2, i, ra); @@ -520,8 +519,8 @@ static uint32_t do_helper_mvc(CPUS390XState *env, uint32_t l, uint64_t dest, /* MVC always copies one more byte than specified - maximum is 256 */ l++; - srca = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); /* * "When the operands overlap, the result is obtained as if the operands @@ -559,8 +558,8 @@ void HELPER(mvcrl)(CPUS390XState *env, uint64_t l, uint64_t dest, uint64_t src) /* MVCRL always copies one more byte than specified - maximum is 256 */ l++; - srca = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); for (i = l - 1; i >= 0; i--) { uint8_t byte = access_get_byte(env, &srca, i, ra); @@ -580,8 +579,8 @@ void HELPER(mvcin)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) l++; src = wrap_address(env, src - l + 1); - srca = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); for (i = 0; i < l; i++) { const uint8_t x = access_get_byte(env, &srca, l - i - 1, ra); @@ -600,9 +599,9 @@ void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) /* MVN always copies one more byte than specified - maximum is 256 */ l++; - srca1 = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); - srca2 = access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); for (i = 0; i < l; i++) { const uint8_t x = (access_get_byte(env, &srca1, i, ra) & 0x0f) | (access_get_byte(env, &srca2, i, ra) & 0xf0); @@ -623,8 +622,8 @@ void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) S390Access srca, desta; int i, j; - srca = access_prepare(env, src, len_src, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, len_dest, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca, env, src, len_src, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, len_dest, MMU_DATA_STORE, mmu_idx, ra); /* Handle rightmost byte */ byte_dest = cpu_ldub_data_ra(env, dest + len_dest - 1, ra); @@ -656,9 +655,9 @@ void HELPER(mvz)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) /* MVZ always copies one more byte than specified - maximum is 256 */ l++; - srca1 = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra); - srca2 = access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca1, env, src, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&srca2, env, dest, l, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, l, MMU_DATA_STORE, mmu_idx, ra); for (i = 0; i < l; i++) { const uint8_t x = (access_get_byte(env, &srca1, i, ra) & 0xf0) | (access_get_byte(env, &srca2, i, ra) & 0x0f); @@ -1005,8 +1004,8 @@ uint32_t HELPER(mvst)(CPUS390XState *env, uint32_t r1, uint32_t r2) * this point). We might over-indicate watchpoints within the pages * (if we ever care, we have to limit processing to a single byte). */ - srca = access_prepare(env, s, len, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, d, len, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca, env, s, len, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, d, len, MMU_DATA_STORE, mmu_idx, ra); for (i = 0; i < len; i++) { const uint8_t v = access_get_byte(env, &srca, i, ra); @@ -1093,19 +1092,19 @@ static inline uint32_t do_mvcl(CPUS390XState *env, len = MIN(MIN(*srclen, -(*src | TARGET_PAGE_MASK)), len); *destlen -= len; *srclen -= len; - srca = access_prepare(env, *src, len, MMU_DATA_LOAD, mmu_idx, ra); - desta = access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&srca, env, *src, len, MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, *dest, len, MMU_DATA_STORE, mmu_idx, ra); access_memmove(env, &desta, &srca, ra); *src = wrap_address(env, *src + len); *dest = wrap_address(env, *dest + len); } else if (wordsize == 1) { /* Pad the remaining area */ *destlen -= len; - desta = access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&desta, env, *dest, len, MMU_DATA_STORE, mmu_idx, ra); access_memset(env, &desta, pad, ra); *dest = wrap_address(env, *dest + len); } else { - desta = access_prepare(env, *dest, len, MMU_DATA_STORE, mmu_idx, ra); + access_prepare(&desta, env, *dest, len, MMU_DATA_STORE, mmu_idx, ra); /* The remaining length selects the padding byte. */ for (i = 0; i < len; (*destlen)--, i++) { @@ -1161,16 +1160,16 @@ uint32_t HELPER(mvcl)(CPUS390XState *env, uint32_t r1, uint32_t r2) while (destlen) { cur_len = MIN(destlen, -(dest | TARGET_PAGE_MASK)); if (!srclen) { - desta = access_prepare(env, dest, cur_len, MMU_DATA_STORE, mmu_idx, - ra); + access_prepare(&desta, env, dest, cur_len, + MMU_DATA_STORE, mmu_idx, ra); access_memset(env, &desta, pad, ra); } else { cur_len = MIN(MIN(srclen, -(src | TARGET_PAGE_MASK)), cur_len); - srca = access_prepare(env, src, cur_len, MMU_DATA_LOAD, mmu_idx, - ra); - desta = access_prepare(env, dest, cur_len, MMU_DATA_STORE, mmu_idx, - ra); + access_prepare(&srca, env, src, cur_len, + MMU_DATA_LOAD, mmu_idx, ra); + access_prepare(&desta, env, dest, cur_len, + MMU_DATA_STORE, mmu_idx, ra); access_memmove(env, &desta, &srca, ra); src = wrap_address(env, src + cur_len); srclen -= cur_len; @@ -2329,8 +2328,8 @@ uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2, return cc; } - srca = access_prepare(env, a2, l, MMU_DATA_LOAD, MMU_PRIMARY_IDX, ra); - desta = access_prepare(env, a1, l, MMU_DATA_STORE, MMU_SECONDARY_IDX, ra); + access_prepare(&srca, env, a2, l, MMU_DATA_LOAD, MMU_PRIMARY_IDX, ra); + access_prepare(&desta, env, a1, l, MMU_DATA_STORE, MMU_SECONDARY_IDX, ra); access_memmove(env, &desta, &srca, ra); return cc; } @@ -2363,9 +2362,8 @@ uint32_t HELPER(mvcp)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2, } else if (!l) { return cc; } - - srca = access_prepare(env, a2, l, MMU_DATA_LOAD, MMU_SECONDARY_IDX, ra); - desta = access_prepare(env, a1, l, MMU_DATA_STORE, MMU_PRIMARY_IDX, ra); + access_prepare(&srca, env, a2, l, MMU_DATA_LOAD, MMU_SECONDARY_IDX, ra); + access_prepare(&desta, env, a1, l, MMU_DATA_STORE, MMU_PRIMARY_IDX, ra); access_memmove(env, &desta, &srca, ra); return cc; } @@ -2706,10 +2704,12 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t dest, uint64_t src, /* FIXME: Access using correct keys and AR-mode */ if (len) { - S390Access srca = access_prepare(env, src, len, MMU_DATA_LOAD, - mmu_idx_from_as(src_as), ra); - S390Access desta = access_prepare(env, dest, len, MMU_DATA_STORE, - mmu_idx_from_as(dest_as), ra); + S390Access srca, desta; + + access_prepare(&srca, env, src, len, MMU_DATA_LOAD, + mmu_idx_from_as(src_as), ra); + access_prepare(&desta, env, dest, len, MMU_DATA_STORE, + mmu_idx_from_as(dest_as), ra); access_memmove(env, &desta, &srca, ra); } From patchwork Mon Jan 9 20:18:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640702 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2341701pvb; Mon, 9 Jan 2023 12:26:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXuZmrWEdiVlkzxa9Uc3RiPemDXiyQs36t+oPqeI5ZUIJOe0T1n2wKT0Gvvsdt8TQd0yii8B X-Received: by 2002:a05:622a:6206:b0:3ae:bd53:dfd2 with SMTP id hj6-20020a05622a620600b003aebd53dfd2mr2021153qtb.41.1673295978088; Mon, 09 Jan 2023 12:26:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295978; cv=none; d=google.com; s=arc-20160816; b=LUHqqYWwd6TXkhGKHJ0jrIxwg6XvQgBnwBOMNtSwkph8N2L2/phflW+w4VdxHhbTYK Z3hA5GlhAoKdkYp6XJ8WQI8gYPF7xXm4WTAOfPlYyBYjyxcrqLBdjTu2SCbyBu5XJuoe 5Q1vIIQbnR17nIZskCEl1qa1i/9cFDerWwxBK/vC0Eehj88oFhwFmyfD1mmD+19xSnEU GyNVWly1GeqtDTCXn2ieiY31Vx0/BM6qstBSSXBBnelKumF7IObp+r2X4xbBhTSj2AmH zMIsiC+yPuash9zcZc3gkPhtdCxTaUHnA7GIIWenzJ6Adwvp5HNVvQjHjzBPnL2TP9vh iSkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zltlvjlCUn0zx1Lgpw9up7wSOYc3XGuPw4RO2nRN2MM=; b=wI8oxeTGVRjyA/YPVAXIXpCr/vFWrzHIjyWVqSkGwEKkGpMQuksOoQCK8iKswZSQgb iovRS1Fpv2mI80n3BMopygKaLs9Ttci3HhTt1RzNDMWN9i51hpjtEAI8Qb4TqPbTCLAw bBuKe1bmNFHI3L4GpiojguITegNblQbtOVtuiQoK7ZoORWMVusq37u9CaH/nZsgal6eY 1HP+lHYKProKsjc1A6t/ne/1OUnKv7ZxgsMPnYyQW+gQv1FfCX4XFgo5wq917c63wkYJ SO8RGyIuKWUHAmy62+J6fU3uKIGkRoUiz1OocSwR9p3mDmpi3kL2Zf0+BTFKUMeOVvsF XVSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W6Ya5WIZ; 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 u8-20020a05622a17c800b003aeadf20157si756009qtk.656.2023.01.09.12.26.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 12:26:18 -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=pass header.i=@linaro.org header.s=google header.b=W6Ya5WIZ; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEybu-0005FR-60; Mon, 09 Jan 2023 15:19:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEybp-00052q-DI for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:05 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEybn-00054B-Sg for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:05 -0500 Received: by mail-pf1-x431.google.com with SMTP id g20so7071612pfb.3 for ; Mon, 09 Jan 2023 12:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zltlvjlCUn0zx1Lgpw9up7wSOYc3XGuPw4RO2nRN2MM=; b=W6Ya5WIZXKBPN3O6d17dcnSVXs8mXsYVsi87ID324ANlXqpEuWgpOpBYp5Lfk3GflV yM7HJZr8W/qKJLdgvaG5otZsDXY5Kxx38nIJNdGEiY38jqsrogBNi1nso4+4gYefpgBz RD5ab23aqr/GcsPhC6g8wQ4UqiVZinPWf1/YEK2QKBBwzYYXJjlgb7lotXK6XR4V8ok4 p8z3lfLX3CsJo+LjS+jtLHRPE8bkzt6qequufwjALnpoQ2rh7ndb51ytY4C8T3kImF1K ByaXU17ifrR3ycihB2nTJnRuJgFgULK2F5IZLMfxFYL2V9GqAFxRZKghJEboiVoQxy4X ntUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zltlvjlCUn0zx1Lgpw9up7wSOYc3XGuPw4RO2nRN2MM=; b=1rX6oOc5Z58Zn3cLfsvqaVTyJ7JG/YUh40HCgngawvrNRzwCo8upNSSJFHGEPlF5EO u1T5wyYUQCZskc/fgmZpx/E4A1pJmhEeob/tuu7EkzsdbZ8ZjohKJsJ7lJ/LlNf+iwpw BhjVJDhAHBVILB8HI5okhLZ5CfRia9pt94G6zh/Swgz4K4zytn1A3XUoyB+1EHhRP0Nn /MdOLZ7HW1fTvj4em82Jkh+IHxn8e6TEIwuBVDuajh+eBcIYugKosJbgGRHfFthAx5bk 9LwiWtZL7hiLIPv40aLcmGS9N2fxDjuIX45tc6m0/IerSZf1qUfjQraii1qrvha+e7jN b81w== X-Gm-Message-State: AFqh2kpB2Ja60A8jviievmwjup8C9E+k6bUSUj14d0aXwpkzaW8Inzdg xXDwtW+Do2OWuqP/Mqvc/y6uyLAQgAqjgS9G X-Received: by 2002:a62:ed18:0:b0:574:cc3d:a24e with SMTP id u24-20020a62ed18000000b00574cc3da24emr58468547pfh.5.1673295541179; Mon, 09 Jan 2023 12:19:01 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:158e:facf:7a46:ba9f]) by smtp.gmail.com with ESMTPSA id c132-20020a621c8a000000b00589a7824703sm1470972pfc.194.2023.01.09.12.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 12:19:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: david@redhat.com Subject: [PATCH 3/7] target/s390x: Use void* for haddr in S390Access Date: Mon, 9 Jan 2023 12:18:52 -0800 Message-Id: <20230109201856.3916639-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109201856.3916639-1-richard.henderson@linaro.org> References: <20230109201856.3916639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The interface from probe_access_flags is void*, and matching that will be helpful. We already rely on the gcc extension for byte arithmetic on void*. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- target/s390x/tcg/mem_helper.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 6a50189ef0..0f2830f87c 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -114,8 +114,8 @@ static inline void cpu_stsize_data_ra(CPUS390XState *env, uint64_t addr, typedef struct S390Access { target_ulong vaddr1; target_ulong vaddr2; - char *haddr1; - char *haddr2; + void *haddr1; + void *haddr2; uint16_t size1; uint16_t size2; /* @@ -268,8 +268,9 @@ static void access_memset(CPUS390XState *env, S390Access *desta, desta->mmu_idx, ra); } -static uint8_t do_access_get_byte(CPUS390XState *env, vaddr vaddr, char **haddr, - int offset, int mmu_idx, uintptr_t ra) +static uint8_t do_access_get_byte(CPUS390XState *env, vaddr vaddr, + void **haddr, int offset, + int mmu_idx, uintptr_t ra) { #ifdef CONFIG_USER_ONLY return ldub_p(*haddr + offset); @@ -301,7 +302,7 @@ static uint8_t access_get_byte(CPUS390XState *env, S390Access *access, offset - access->size1, access->mmu_idx, ra); } -static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, char **haddr, +static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, void **haddr, int offset, uint8_t byte, int mmu_idx, uintptr_t ra) { From patchwork Mon Jan 9 20:18:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640695 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2340679pvb; Mon, 9 Jan 2023 12:23:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXu4P8RQ15wbbSD63KFRz9LzxquSa7TGg6/HJClPUXEdNw3bKBv59BsxgauMH5MAYT1tRQxR X-Received: by 2002:ac8:138c:0:b0:3a5:758d:8f5e with SMTP id h12-20020ac8138c000000b003a5758d8f5emr524545qtj.19.1673295827789; Mon, 09 Jan 2023 12:23:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295827; cv=none; d=google.com; s=arc-20160816; b=kSzn1mDeHkIxm3MZPbL5x4uvBkQz1fCA3fkf0VMS/QbX35cmPXbsA9KXCE+VQ7/3O0 bME0AczpCI8zuLSIbYMnCtVSCEjr6KFu43/c+oJovJKI3ThYzX2Vecz3X+ZQWhtdq2L2 nlcOigUpWOG9VJQhQffUv9Q7g3XR17JUzBKTBiV01cikhEMrr/lsKgyjfDe52T3JQzKk ilxOCkyL6rWm4HHKqJm9V3iErznGcOseWgwSPiT2VardX5Fo/JeGbfnyGvvVOawrR5a6 KTm7lHjWst0k3kgr52Y/QDGEdyXszVDUNQft+IlKgMyhnnznpvrr2RZb0QdxYn/530Dm Ft8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8X0Lb47wJgNa3+w7lfIg0QENGe9Mb2V6lxaP2jwNHKI=; b=cwAnED57adIHnGujxeHWeS/zOUcwszej1yOmPQNmYQ90/fJ+WTJ9Qe6BkHZcpbLmhn ay5HKca/CiXGg/6nsBVyISsH+CShudBDpvzt2tsjE/OB5QCOimqAV0Sq4mOKBjJKmbO9 9Z4EJ59+SnHAtIme/+euy2YE+h6/crqeRUs8TV1OIRXjtUuE0h+SZmYsoMKIxWymBErI TC+5LLdekYi/BPll/9KnmPSXYL4B9YkgOiJUo8iMdkdgsyqDx+0bTgQ4OuOUml7cJpnV YdkFQY6MEmrUZeWmEYSZwaoc/MLI1BGTWOz+9Y8ar4Ux1fkLKfUwj8fqJFUPpB0AYZNo VCsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=twr0gZmU; 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 q15-20020ac8450f000000b003a7f0fdcfeesi4978609qtn.687.2023.01.09.12.23.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 12:23:47 -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=pass header.i=@linaro.org header.s=google header.b=twr0gZmU; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEybs-00059s-HI; Mon, 09 Jan 2023 15:19:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEybq-00055S-Nj for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:06 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEybp-00054Z-0J for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:06 -0500 Received: by mail-pg1-x532.google.com with SMTP id 7so6704976pga.1 for ; Mon, 09 Jan 2023 12:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8X0Lb47wJgNa3+w7lfIg0QENGe9Mb2V6lxaP2jwNHKI=; b=twr0gZmUV6fN+Du5d91yAjQ9SBJfYyWIm83jMP8+H/BeeqVEcWQKuh95m21ouP3fJQ eCljOTwCRh9/anUBrMNRRuo/MqpodU7bTaKIkUiXsgLaNp++8dxCgec+3pHHsD73F2oV unXdYO/U+9oK81QvLP6z5O/Xp8UCpd1Xz/wKaj7/kKpicp9VN/75h14o0K+J3C+ywqIt kBdnnBKPMTDx8bRNiJgUW8YrKDXStwZ354ax2m1lyddNAQw4i4mh16xwPu1D6Mq91U+j W4a1t2GQPkQ6YsljwCCZKwfaxq2FgsQWDojrIGRAXbuIyQtw1hEant1SoBjPrwa75xeS Tz5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8X0Lb47wJgNa3+w7lfIg0QENGe9Mb2V6lxaP2jwNHKI=; b=EE8f2jPtkhGtACOrKER74LOCM94FE7GVOe7A2dQIydWpTovUxWraSoKSkJPOmoCUbL 8q9eUd1SdOs2nD7nGjcJE1o94YXL5MPGsIChyTlfJPtdGM0Vp4wiKOrV6y4Pl91DLM+w D+RzBL3nO0PrNKBsIs8fVqwCaLD8WdslzJvMhXNE0dzBiMXngDVIR4IP8ASD2ewO5hyG fVdFxz38uCxJBRnYg4StWdy6ag6PsSVq9rrYSGsWZo+W/spOr0LlcXaaY5A0PKogkE/1 cJWyhfcJwuWSn2YLPqqXTw2J+kg4YziDecazNltXgs7Su2x4flawbvWH+gXGr5OX4HFB 1zBg== X-Gm-Message-State: AFqh2kpkiONagJW/cPlwRbO6g+TPdNPAiYyR+3ns0ib3kBZ3paoRgGfV JukV2Coa0EaJ8mmo20Dm34E8FyP5EuJJyUhs X-Received: by 2002:aa7:8286:0:b0:57e:c106:d50c with SMTP id s6-20020aa78286000000b0057ec106d50cmr71768699pfm.17.1673295542129; Mon, 09 Jan 2023 12:19:02 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:158e:facf:7a46:ba9f]) by smtp.gmail.com with ESMTPSA id c132-20020a621c8a000000b00589a7824703sm1470972pfc.194.2023.01.09.12.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 12:19:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: david@redhat.com Subject: [PATCH 4/7] target/s390x: Tidy access_prepare_nf Date: Mon, 9 Jan 2023 12:18:53 -0800 Message-Id: <20230109201856.3916639-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109201856.3916639-1-richard.henderson@linaro.org> References: <20230109201856.3916639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Assign to access struct immediately, rather than waiting until the end of the function. This means we can pass address of haddr struct members instead of allocating extra space on the local stack. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- target/s390x/tcg/mem_helper.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 0f2830f87c..59237fe7de 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -176,39 +176,35 @@ static int access_prepare_nf(S390Access *access, CPUS390XState *env, MMUAccessType access_type, int mmu_idx, uintptr_t ra) { - void *haddr1, *haddr2 = NULL; int size1, size2, exc; - vaddr vaddr2 = 0; assert(size > 0 && size <= 4096); size1 = MIN(size, -(vaddr1 | TARGET_PAGE_MASK)), size2 = size - size1; + memset(access, 0, sizeof(*access)); + access->vaddr1 = vaddr1; + access->size1 = size1; + access->size2 = size2; + access->mmu_idx = mmu_idx; + exc = s390_probe_access(env, vaddr1, size1, access_type, mmu_idx, nonfault, - &haddr1, ra); - if (exc) { + &access->haddr1, ra); + if (unlikely(exc)) { return exc; } if (unlikely(size2)) { /* The access crosses page boundaries. */ - vaddr2 = wrap_address(env, vaddr1 + size1); + vaddr vaddr2 = wrap_address(env, vaddr1 + size1); + + access->vaddr2 = vaddr2; exc = s390_probe_access(env, vaddr2, size2, access_type, mmu_idx, - nonfault, &haddr2, ra); - if (exc) { + nonfault, &access->haddr2, ra); + if (unlikely(exc)) { return exc; } } - - *access = (S390Access) { - .vaddr1 = vaddr1, - .vaddr2 = vaddr2, - .haddr1 = haddr1, - .haddr2 = haddr2, - .size1 = size1, - .size2 = size2, - .mmu_idx = mmu_idx - }; return 0; } From patchwork Mon Jan 9 20:18:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640701 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2341658pvb; Mon, 9 Jan 2023 12:26:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXuIrnacZFNZXmnw07CqOcWA+qAbmRuhgVlIsZNWm9COD808pEjNwuRjktt1Rb40qp2FbRm0 X-Received: by 2002:ad4:5287:0:b0:532:3194:8433 with SMTP id v7-20020ad45287000000b0053231948433mr4809216qvr.35.1673295969379; Mon, 09 Jan 2023 12:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295969; cv=none; d=google.com; s=arc-20160816; b=cAlBMbJBjp27kKGLk2WZHGn6nxSJ7cYx10D/U0JGtW8cWX9+B27KhEVdBHwavWmTSV dtcgEIAJbDZx+zgCcGW6yK5j1FTfMA/zSmN7YETHiM5/3Ih3fCeV0RnRhxVIA+dLWtzr Ey6BVCI5/4L5QG+MmGAWGb/QYGaZqX5mBUsTSIR6GZTxLSot9fHB5mqz3mGmlbun3iH7 dh1ed9q9If4ozrgJmY+cj6EatSlqK3HdaFLJoYGKYUMaoAQioFW+f9tcoCgSApa+beAv 7Bq3RBrkpqkWYHxu9IJA31nijbUvgsSCUVguBTQDvhCYh9k3R97AfVvnRkFGO74Zx+SA huXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g5hENHTKdMqEDVIFMgyawVY+dMepGnLmDVP7rciuUSE=; b=sHqowHW07rbkSQanWT+wGwrTERQhs8zJjijWDDbN7BM1ASvokt3YzXbrDGt7Au6ODH FmE/d3pkx79NZspZ65rBPd38dCYNny87AK5nJjjAsts1s6koBpiLOhgZozQ/PhsLyk/L yoEqIOi+4UnOeNStbYEy20yudtN+PwGCexncM+RxseMaoO5voUYVltyWK3z+XOPyAl+v Iavm7V7pO+AeU0/Od1o3wk3Wz1Dv80ZoEqv+Yd0sPeKaSBPtdRHGwn93RMvL3FopC8OP 93YasO9lETrgNwRJipiiHWS1TOBu8FLf3yuM1FLWMwN9TIYD0YQERUOyCDNyhGKDzFre W7wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HyrFRV47; 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 li19-20020a0562145e1300b004c6e387d48dsi4504840qvb.190.2023.01.09.12.26.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 12:26:09 -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=pass header.i=@linaro.org header.s=google header.b=HyrFRV47; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEybr-00057a-Ks; Mon, 09 Jan 2023 15:19:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEybq-00054K-7W for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:06 -0500 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEybo-00054K-DP for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:05 -0500 Received: by mail-pg1-x52f.google.com with SMTP id f3so6700809pgc.2 for ; Mon, 09 Jan 2023 12:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g5hENHTKdMqEDVIFMgyawVY+dMepGnLmDVP7rciuUSE=; b=HyrFRV47HBoMVC6aOONau/sq0P8qTuPGsqYmcvO3WbSymbBGb1CASSWMyKwzs6APjV g9nRj2Rj1G5Mq5tSMDfN3UXgqW0YQrSCmHvD+GriTB71Juehdjko7Yiuq2h/Uo8MUaBt obDLTG/DbFRUR8VVHdhX7sZoJBINJnwX7YxzVbdqYcmnPciSnS3Eqb7YNsl8rvVQSVNY ozKrwh6XpvcoabVskUG3BhRSXjF0pkUjDukfS/CD4k7xHGrExRgrbawvyKsEcwxoXm5Z w/kZ8beZNYqXja/GX4OjXn/FR1pHZ95qwnMKmtIFX/QpLDsanKoMlofJKqsOs/7pjQr2 jWUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g5hENHTKdMqEDVIFMgyawVY+dMepGnLmDVP7rciuUSE=; b=ZTZloSpsGu5waTWfBU/sn4OBbGT74xfMshLP0XFhIrznK0qifUz9guFzh9W1GLH3eH /aceUdvcSQyo9tT9LjYppoMpyeId9khxB5iQj/QzJSZnbMquvA13TnBnugTWUwZBf8Lo XXGXwCrPNPt6f9kddT7EHcfUBkZxgAD1N1dzMz9X5LrCYtKFTJsqSmJk8E9uTs3Zheh4 4rkn/+aBFMX9kn5fLzq74AFTG+cl4zVtRGR9FrILzM1MOTDGASgKFuY/29gIHbz80r6S AsoC0w+avafaMJUisjaAV1/kBts8WtTIZmrF4WcN2zqIKRjqyHkuJqm9AMuAul0DjjFH dgcQ== X-Gm-Message-State: AFqh2kpjf1Vr/RCtWS0GfpxP6/ut4N+Xu2q9TTdqqMj9TQiEdMvNJIEv Co00aXfHFDr5Eka1HVsY7RE2cBmNd19VpBBw X-Received: by 2002:a05:6a00:d77:b0:587:102b:edb6 with SMTP id n55-20020a056a000d7700b00587102bedb6mr7671972pfv.17.1673295542986; Mon, 09 Jan 2023 12:19:02 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:158e:facf:7a46:ba9f]) by smtp.gmail.com with ESMTPSA id c132-20020a621c8a000000b00589a7824703sm1470972pfc.194.2023.01.09.12.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 12:19:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: david@redhat.com Subject: [PATCH 5/7] target/s390x: Remove TLB_NOTDIRTY workarounds Date: Mon, 9 Jan 2023 12:18:54 -0800 Message-Id: <20230109201856.3916639-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109201856.3916639-1-richard.henderson@linaro.org> References: <20230109201856.3916639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When this code was written, it was using tlb_vaddr_to_host, which does not handle TLB_DIRTY. Since then, it has been converted to probe_access_flags, which does. Signed-off-by: Richard Henderson Acked-by: David Hildenbrand --- target/s390x/tcg/mem_helper.c | 74 +++++++++++------------------------ 1 file changed, 22 insertions(+), 52 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 59237fe7de..f7dc710814 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -122,11 +122,7 @@ typedef struct S390Access { * If we can't access the host page directly, we'll have to do I/O access * via ld/st helpers. These are internal details, so we store the * mmu idx to do the access here instead of passing it around in the - * helpers. Maybe, one day we can get rid of ld/st access - once we can - * handle TLB_NOTDIRTY differently. We don't expect these special accesses - * to trigger exceptions - only if we would have TLB_NOTDIRTY on LAP - * pages, we might trigger a new MMU translation - very unlikely that - * the mapping changes in between and we would trigger a fault. + * helpers. */ int mmu_idx; } S390Access; @@ -224,28 +220,14 @@ static void do_access_memset(CPUS390XState *env, vaddr vaddr, char *haddr, uintptr_t ra) { #ifdef CONFIG_USER_ONLY - g_assert(haddr); memset(haddr, byte, size); #else - MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); - int i; - if (likely(haddr)) { memset(haddr, byte, size); } else { - /* - * Do a single access and test if we can then get access to the - * page. This is especially relevant to speed up TLB_NOTDIRTY. - */ - g_assert(size > 0); - cpu_stb_mmu(env, vaddr, byte, oi, ra); - haddr = tlb_vaddr_to_host(env, vaddr, MMU_DATA_STORE, mmu_idx); - if (likely(haddr)) { - memset(haddr + 1, byte, size - 1); - } else { - for (i = 1; i < size; i++) { - cpu_stb_mmu(env, vaddr + i, byte, oi, ra); - } + MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); + for (int i = 0; i < size; i++) { + cpu_stb_mmu(env, vaddr + i, byte, oi, ra); } } #endif @@ -265,25 +247,18 @@ static void access_memset(CPUS390XState *env, S390Access *desta, } static uint8_t do_access_get_byte(CPUS390XState *env, vaddr vaddr, - void **haddr, int offset, + void *haddr, int offset, int mmu_idx, uintptr_t ra) { #ifdef CONFIG_USER_ONLY - return ldub_p(*haddr + offset); + return ldub_p(haddr + offset); #else - MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); - uint8_t byte; - - if (likely(*haddr)) { - return ldub_p(*haddr + offset); + if (likely(haddr)) { + return ldub_p(haddr + offset); + } else { + MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); + return cpu_ldb_mmu(env, vaddr + offset, oi, ra); } - /* - * Do a single access and test if we can then get access to the - * page. This is especially relevant to speed up TLB_NOTDIRTY. - */ - byte = cpu_ldb_mmu(env, vaddr + offset, oi, ra); - *haddr = tlb_vaddr_to_host(env, vaddr, MMU_DATA_LOAD, mmu_idx); - return byte; #endif } @@ -291,32 +266,27 @@ static uint8_t access_get_byte(CPUS390XState *env, S390Access *access, int offset, uintptr_t ra) { if (offset < access->size1) { - return do_access_get_byte(env, access->vaddr1, &access->haddr1, + return do_access_get_byte(env, access->vaddr1, access->haddr1, offset, access->mmu_idx, ra); } - return do_access_get_byte(env, access->vaddr2, &access->haddr2, + return do_access_get_byte(env, access->vaddr2, access->haddr2, offset - access->size1, access->mmu_idx, ra); } -static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, void **haddr, +static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, void *haddr, int offset, uint8_t byte, int mmu_idx, uintptr_t ra) { #ifdef CONFIG_USER_ONLY - stb_p(*haddr + offset, byte); + stb_p(haddr + offset, byte); #else - MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); - if (likely(*haddr)) { - stb_p(*haddr + offset, byte); - return; + if (likely(haddr)) { + stb_p(haddr + offset, byte); + } else { + MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); + cpu_stb_mmu(env, vaddr + offset, byte, oi, ra); } - /* - * Do a single access and test if we can then get access to the - * page. This is especially relevant to speed up TLB_NOTDIRTY. - */ - cpu_stb_mmu(env, vaddr + offset, byte, oi, ra); - *haddr = tlb_vaddr_to_host(env, vaddr, MMU_DATA_STORE, mmu_idx); #endif } @@ -324,10 +294,10 @@ static void access_set_byte(CPUS390XState *env, S390Access *access, int offset, uint8_t byte, uintptr_t ra) { if (offset < access->size1) { - do_access_set_byte(env, access->vaddr1, &access->haddr1, offset, byte, + do_access_set_byte(env, access->vaddr1, access->haddr1, offset, byte, access->mmu_idx, ra); } else { - do_access_set_byte(env, access->vaddr2, &access->haddr2, + do_access_set_byte(env, access->vaddr2, access->haddr2, offset - access->size1, byte, access->mmu_idx, ra); } } From patchwork Mon Jan 9 20:18:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640700 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2341562pvb; Mon, 9 Jan 2023 12:25:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXtu9Lbk4Cd2xw8dsc+rcmlSgEY7j0u/kg/VDNvgU1vi9WfUL9HFRDkVnSAOUmvM/Omu/Lyt X-Received: by 2002:ad4:551d:0:b0:4d1:e110:1621 with SMTP id pz29-20020ad4551d000000b004d1e1101621mr87501578qvb.0.1673295954024; Mon, 09 Jan 2023 12:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295954; cv=none; d=google.com; s=arc-20160816; b=ftVtTAfcOkHoRQlK5jX93BCeyCZqwo7V4ScEqibJCplb886RHHODjWkVvhiz0MZdae 6QSvVoYQVLEKq6J02kUphXEccDPaEgGXGNs51VmdSFw8WMvptwvAiNXeWQHcf+bp5vPz LpUAdWrIvMcItGlcX3tA3O76DrifkmgNLbLLZwwFh/Vni2YtaKzO4mQ7UTQvZMMZKl6R m4C4TQeHtcPSiVbtshFyGaMAG5qZ7yFK2bVomsk2Qv3C2RmxIub/LifuzBotBJyFDVZw UjjHvHX1egsOjGIrcp+Fa3AVrW/1NLM5koidu+UT1PWxQK5TNT+CHZO7cumPp4X9JNbK mZxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iqqpjlza/yK0HsDNhpb8C0T7r/IzSeSCH09wUywlg8k=; b=XV3xlWZIYth885XPTCae4LqhDf4kLnsbTjKjOJn44Ledf/o9V2gry1o7O61Y2uus/4 t/iirtF/rX9kiK/B3w8mGD+3f1KxarsIL/ZsaKwt54r6LzpwFmzqZt4CyFs48M0XvHrE SrvFD0coofZ7xTTXkkclc8DhfOhj6POI8Nb5liBBkliQvhObE3WSxHTLbovCLEpudtQU /ovk3T13hYkBS/ComwSlCOFfImVYLBYRZgvg2qVDHqMow3U8TaxyIxu3o9awpAbkTZ7Z 1jX/hRdBVFeGiH8YU+yEyr9nPh7QEEt9b8M9OQFh/pHO1eiilvOqAvI6pufLIjW3YbsX Jtmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nps7CHq+; 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 p14-20020a05620a112e00b00705b942a3cbsi1898136qkk.147.2023.01.09.12.25.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 12:25:54 -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=pass header.i=@linaro.org header.s=google header.b=Nps7CHq+; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEybu-0005HR-S3; Mon, 09 Jan 2023 15:19:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEybr-00056C-1U for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:07 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEybp-00054g-7k for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:06 -0500 Received: by mail-pl1-x632.google.com with SMTP id d3so10781368plr.10 for ; Mon, 09 Jan 2023 12:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iqqpjlza/yK0HsDNhpb8C0T7r/IzSeSCH09wUywlg8k=; b=Nps7CHq+IOjCm0YfB0rvtWHeSLe+JUVkX5GGPi+tTiVuUgorxG38J/tysW5Uk0NOUk vbGqET/edUAWXPzv2Vk1IOG5SSaPg/vs2+hIPXlYxNLuUP4NKsZlYSGIyZj1dgDOhKdR A9JtsV9VOebj9Lzuwax2lUpkvLS0MyU5zoRYKJBTXAZYVXpH5VV+5I+8lY2Oxbt9k/fZ ETC3djY79KSQKTs0/ZjBVKZhnm1MVjZIItXzvPeNTeykwP0sXGyDgWJ34e4YKOvdta+m CHKIq/xVGp3MtX4Su04k25SqYrcsvk2KaBZymSBXAMyEPvnO5m08Aaj69REpatBoaNUm VNrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iqqpjlza/yK0HsDNhpb8C0T7r/IzSeSCH09wUywlg8k=; b=qHxVdKCygccWIRbxrj2VRU2AvwMGmAbKM4TwE9/qLT2m3lxsvotWNMYPgoyxBwx2Sv 1oYHIoKShzH53vfYE7tbAb93k1tYVPgvqF6r0eq0oGAiHdKuxBE6kib/w82w9EkZGL5e 4/wJlEItnkTrqtmAUyrqDjcwmbquG+f0TupzipDABqDSUNxZEwF8SKRYi5p0s93i8xIU JdAHyjyO3/IUony/NttyPLi13BVKLpNKwzf53+0roU9eKid6sotwjDZl0wTlPucZBAre dOyMy+/DUozxOFavhI3NQIeF9SoRGJSzxG/INdCVdxBbsC1D6I4rFdQYEElRPRoxP34o gEBQ== X-Gm-Message-State: AFqh2kp00+2x5ZtZ5RGTGyNzRPjDuhCg85//g5FBYWjTiJzwlSb7H83B bJfYwk3R5d9lPe1+RqY28KPGPjp0mb1e9c2w X-Received: by 2002:a05:6a20:94c6:b0:ad:aaac:d40b with SMTP id ht6-20020a056a2094c600b000adaaacd40bmr78778140pzb.45.1673295543865; Mon, 09 Jan 2023 12:19:03 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:158e:facf:7a46:ba9f]) by smtp.gmail.com with ESMTPSA id c132-20020a621c8a000000b00589a7824703sm1470972pfc.194.2023.01.09.12.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 12:19:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: david@redhat.com Subject: [PATCH 6/7] target/s390x: Inline do_access_{get,set}_byte Date: Mon, 9 Jan 2023 12:18:55 -0800 Message-Id: <20230109201856.3916639-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109201856.3916639-1-richard.henderson@linaro.org> References: <20230109201856.3916639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Inline into the parent functions with a simple test to select the page, and a new define to remove ifdefs. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- target/s390x/tcg/mem_helper.c | 70 +++++++++++++++-------------------- 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index f7dc710814..92eb6564c3 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -35,6 +35,12 @@ #include "hw/boards.h" #endif +#ifdef CONFIG_USER_ONLY +# define user_or_likely(X) true +#else +# define user_or_likely(X) likely(X) +#endif + /*****************************************************************************/ /* Softmmu support */ @@ -246,59 +252,43 @@ static void access_memset(CPUS390XState *env, S390Access *desta, desta->mmu_idx, ra); } -static uint8_t do_access_get_byte(CPUS390XState *env, vaddr vaddr, - void *haddr, int offset, - int mmu_idx, uintptr_t ra) -{ -#ifdef CONFIG_USER_ONLY - return ldub_p(haddr + offset); -#else - if (likely(haddr)) { - return ldub_p(haddr + offset); - } else { - MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); - return cpu_ldb_mmu(env, vaddr + offset, oi, ra); - } -#endif -} - static uint8_t access_get_byte(CPUS390XState *env, S390Access *access, int offset, uintptr_t ra) { - if (offset < access->size1) { - return do_access_get_byte(env, access->vaddr1, access->haddr1, - offset, access->mmu_idx, ra); + target_ulong vaddr = access->vaddr1; + void *haddr = access->haddr1; + + if (unlikely(offset >= access->size1)) { + offset -= access->size1; + vaddr = access->vaddr2; + haddr = access->haddr2; } - return do_access_get_byte(env, access->vaddr2, access->haddr2, - offset - access->size1, access->mmu_idx, ra); -} -static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, void *haddr, - int offset, uint8_t byte, int mmu_idx, - uintptr_t ra) -{ -#ifdef CONFIG_USER_ONLY - stb_p(haddr + offset, byte); -#else - - if (likely(haddr)) { - stb_p(haddr + offset, byte); + if (user_or_likely(haddr)) { + return ldub_p(haddr + offset); } else { - MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); - cpu_stb_mmu(env, vaddr + offset, byte, oi, ra); + MemOpIdx oi = make_memop_idx(MO_UB, access->mmu_idx); + return cpu_ldb_mmu(env, vaddr + offset, oi, ra); } -#endif } static void access_set_byte(CPUS390XState *env, S390Access *access, int offset, uint8_t byte, uintptr_t ra) { - if (offset < access->size1) { - do_access_set_byte(env, access->vaddr1, access->haddr1, offset, byte, - access->mmu_idx, ra); + target_ulong vaddr = access->vaddr1; + void *haddr = access->haddr1; + + if (unlikely(offset >= access->size1)) { + offset -= access->size1; + vaddr = access->vaddr2; + haddr = access->haddr2; + } + + if (user_or_likely(haddr)) { + stb_p(haddr + offset, byte); } else { - do_access_set_byte(env, access->vaddr2, access->haddr2, - offset - access->size1, byte, access->mmu_idx, ra); + MemOpIdx oi = make_memop_idx(MO_UB, access->mmu_idx); + cpu_stb_mmu(env, vaddr + offset, byte, oi, ra); } } From patchwork Mon Jan 9 20:18:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640694 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2340356pvb; Mon, 9 Jan 2023 12:22:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXWmCjRaVS+nK87ExMlgNpUK7xgEmJpfVZBBwFgQzDpRam0rsdpkJ3VdZtLpzbvJ5uwJkh X-Received: by 2002:a05:622a:244a:b0:3a8:27b9:5e18 with SMTP id bl10-20020a05622a244a00b003a827b95e18mr105106791qtb.67.1673295778022; Mon, 09 Jan 2023 12:22:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295778; cv=none; d=google.com; s=arc-20160816; b=SKx85jpmtwb7Hz/dBnDtd4EIzrda63+5Cg4hRiOBVAMfLhada2BJZ1Kxv4z5/n4xmo T4EpvWIbBoCl2tKeaNfcZpWZjbbfqReyXrN8z1+AaxvPBSGVE0fXycOzJNoYSM5lG2hU Ds0CD7/E7NFnPnri3c7O0ww3vdZnA49ExGUcrr1sdtFQsIgRqVXOgJ2FfghXvvnOYFyp 5zsgZeq2sF5NxZkoCpIOYBtekWHOC6QqXh+NCcw6vkn9U5xrle6dgICwz6g+AAd9DppQ 7rtVESgwXgEUNu8YT3LNzM4ojsZWVdV8LoK5DnpxU32a7T5L0R3ApzIfh04TyMIRaUI/ 8VeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WTZIs1C/js8Say6SBQT3RKsZE9PwWeX+MiQ9FxoXnQk=; b=Wby8eFJ/PC4zyGPs/NjBTVKZ7faK1D0ZSvPmaXEt7FiDGkRZoYOIhT0TT7sp313wh7 pLsWb7DN949Wos6JKC2yMHPX4+rg5odS8GRxO9aMZ1QnwSZjFfYcrIjMg4H5j04ppYTs coZE8mUtZWnska+FYSAl1Ok5vPU9VBER+oks5ftEZZaORAZyg0VM4BXwYA6hwCiY0FAh c4eqTC8sBjfQ7BNREizV2qvbPIItaAzej+9g0Usugao0iIFjgNWbFh9RCKS5ZWSSsTNF 6VKHW9rOzFs3VMOwHt6gOTgVy/+P+9i1ICrJkl2r3A6FNoZodW8tPPPW5H5qXw3Urjfg ZHQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QoAvLcUU; 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 br24-20020a05622a1e1800b003a52fda7dd8si5123500qtb.17.2023.01.09.12.22.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 12:22: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=pass header.i=@linaro.org header.s=google header.b=QoAvLcUU; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEybt-0005DQ-8D; Mon, 09 Jan 2023 15:19:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEybr-00057m-LU for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:07 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEybp-00052q-Ir for qemu-devel@nongnu.org; Mon, 09 Jan 2023 15:19:07 -0500 Received: by mail-pf1-x430.google.com with SMTP id 20so1660722pfu.13 for ; Mon, 09 Jan 2023 12:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WTZIs1C/js8Say6SBQT3RKsZE9PwWeX+MiQ9FxoXnQk=; b=QoAvLcUU0KM0M9KB6AUycHl6EDECQje+gHbahYD2rjoCGhHYhDAK/YGldxmUH73ZCF gnU02XvmvorXl8kRX0jvI/nvoLxlmTVGDEK8eAzOY6yp0eH7Ut44S1HDHKxI2HWkoz8T KlKz8cyAgFR0GyT5WxeIcStFM19rxGMhuKWDt6EiKziYTmFGddEgfTNQ5rN4rk5WWmaK FWysQuNVAZ+jv+goc1snhfwLx2CF7DwZVkZAAwIH2JH3R6RY4E9DDw1IXrbCB6nOGXoM fkouwCZh0IBaW7n/TCMysJPCN8j8ak+OQFqAIvs4lYkZhPuWrNZ/dgywfKf6IILFrytz ieug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WTZIs1C/js8Say6SBQT3RKsZE9PwWeX+MiQ9FxoXnQk=; b=Pf7qoGvGPIlRvnZDdRMMfv6GvflP+AR7xfD20LLKIvyTW2qrnK/E/G7RbQcAHSqm63 Jvb5cXRlnlJ6ieV4ToyjJQTOsNJpael80fi56cy115+sKtbd4hQU8/NSSXYO3rHHgCpE rP+RsDg3PnPj2BK0QBNWfl4o/waipprp+z/7JQ8sjsWWTfWLp/4pTcjbtwRqUMTxFUBL 8cqwvmCitBuoOdTX/XToGAKJbUITBIQ5LQomuLqnAk/ypvliSbxWF8clETOQ7p6tgJjc U3txPksvWEklN0Bs7WO9sm58Pe07oM2jJ+o/w50qITiLJjgCW5GPlU5YISfm2ApwSDAY WW1w== X-Gm-Message-State: AFqh2kovVpw9zLffSQODCPpy55PLUJTAMmRxV7XdScElUwlcP3pqTDCu i9S+XTvNpqlNyo1kuCoZHE/wNjdI5vnGhvE9 X-Received: by 2002:a05:6a00:1346:b0:581:c216:1390 with SMTP id k6-20020a056a00134600b00581c2161390mr53365972pfu.34.1673295544825; Mon, 09 Jan 2023 12:19:04 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:158e:facf:7a46:ba9f]) by smtp.gmail.com with ESMTPSA id c132-20020a621c8a000000b00589a7824703sm1470972pfc.194.2023.01.09.12.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 12:19:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: david@redhat.com Subject: [PATCH 7/7] target/s390x: Hoist some computation in access_memmove Date: Mon, 9 Jan 2023 12:18:56 -0800 Message-Id: <20230109201856.3916639-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109201856.3916639-1-richard.henderson@linaro.org> References: <20230109201856.3916639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Ensure that the total length is in a local variable across the byte loop. Compute size1 difference once. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- target/s390x/tcg/mem_helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 92eb6564c3..5f0dd67985 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -299,16 +299,17 @@ static void access_set_byte(CPUS390XState *env, S390Access *access, static void access_memmove(CPUS390XState *env, S390Access *desta, S390Access *srca, uintptr_t ra) { + int len = desta->size1 + desta->size2; int diff; - g_assert(desta->size1 + desta->size2 == srca->size1 + srca->size2); + assert(len == srca->size1 + srca->size2); /* Fallback to slow access in case we don't have access to all host pages */ if (unlikely(!desta->haddr1 || (desta->size2 && !desta->haddr2) || !srca->haddr1 || (srca->size2 && !srca->haddr2))) { int i; - for (i = 0; i < desta->size1 + desta->size2; i++) { + for (i = 0; i < len; i++) { uint8_t byte = access_get_byte(env, srca, i, ra); access_set_byte(env, desta, i, byte, ra); @@ -316,20 +317,20 @@ static void access_memmove(CPUS390XState *env, S390Access *desta, return; } - if (srca->size1 == desta->size1) { + diff = desta->size1 - srca->size1; + if (likely(diff == 0)) { memmove(desta->haddr1, srca->haddr1, srca->size1); if (unlikely(srca->size2)) { memmove(desta->haddr2, srca->haddr2, srca->size2); } - } else if (srca->size1 < desta->size1) { - diff = desta->size1 - srca->size1; + } else if (diff > 0) { memmove(desta->haddr1, srca->haddr1, srca->size1); memmove(desta->haddr1 + srca->size1, srca->haddr2, diff); if (likely(desta->size2)) { memmove(desta->haddr2, srca->haddr2 + diff, desta->size2); } } else { - diff = srca->size1 - desta->size1; + diff = -diff; memmove(desta->haddr1, srca->haddr1, desta->size1); memmove(desta->haddr2, srca->haddr1 + desta->size1, diff); if (likely(srca->size2)) {