From nobody Thu May 2 01:42:39 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=1569124631; cv=none; d=zoho.com; s=zohoarc; b=QUlBZywPhsQg4+4JNe9GrxankbCyBfKT1BknoBJJ8NEdNpSb5Q9ic4tEmlgQqJ+ctCubMS5++M+sj7tXAXwf5Fc4J28kdDu5ozW2rBbNzpAEkCvC0M4mMeNdHIos5naZd/662VV5r6Iy4gku/Wi3KdvfPQHdR6i+4wnLphx/Pcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569124631; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=UteKEOffkWeXmOTmYpSFU6ZzU7S3qN8fl2HT/2omIaY=; b=GQz4ebrXTEAqQJaZvClTMu16hHpH+jVPrXV+KcPcqZNjEYv+wn3B1jRXdSTG84LPD2+41cduh3UKWsDpgMHhJSv+03VavIIcnR0yUrcvrVRKsip9C5KpSNf9Ch8v88cQht+HwetaRZUbd2iaDTvBMf95wjxESNn/+wjX3wq0i2o= 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 156912463153626.06315752015348; Sat, 21 Sep 2019 20:57:11 -0700 (PDT) Received: from localhost ([::1]:44890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBszj-0003KD-5e for importer@patchew.org; Sat, 21 Sep 2019 23:57:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40766) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxk-0001Kh-GX for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxj-00084M-BN for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:04 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34345) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxj-000841-5c for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:03 -0400 Received: by mail-pf1-x441.google.com with SMTP id b128so7003035pfa.1 for ; Sat, 21 Sep 2019 20:55:03 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55: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; bh=UteKEOffkWeXmOTmYpSFU6ZzU7S3qN8fl2HT/2omIaY=; b=MHHmAhHsEfUphd6MnrlKA/W1cnrx4nUyZ5aGfqaC/JMopaANhzppmTCapu/jQ6Dp8s +lLWs/weUxgmS1rNfbGKyo1PdueEW4YaP1p18I51YSJuov+twifcHXG7PfbwQPDIWEf6 imKH4WQBcWvCfgfsU7bGEm5RLn+4hh651hrdlSE/QKsoVPVKiggmyVK334yKsSrLhaPS 3jiAgwNxn5JWSV/XWT6899CbVp1diiGEQP6f+nEPN8u+/lvk+OWRwBybBkpOgPd5+zRj wol4xV5BepqGY5Gj1WedXgyxpkJT0+eLDSPf+r6efs7yzUjeC9g9YE5Ouq959/zQMzL5 sGOg== 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=UteKEOffkWeXmOTmYpSFU6ZzU7S3qN8fl2HT/2omIaY=; b=KRtAYrL98VVa+BtGRvGt7C0iYlw9GjH7JtP/G62ZpO8vdaW91RGZY+2FhZ597AMn9N PqQssqF58GM8aOdFHQfL1JD4cRGUTQwneYo/DgwpiRUZiWL1JV29f/kMTeRbCbsl+DoW KMQ0LriPbbpP/LTpK/dtCuxsdX5vBOaBD4Zz6Vs2on0COPoqx4/Y8PTpGwfmc5lTaZz2 F5jT2KjSOu3Q5uXUMdSGJTgAJjEPsat6nPzH9NAHe5vb3g00TBDLqtOpmS/DokCopUVi SbdVruLM58eW0MuFmN6svDgzwvTtX/dC2JthIqG+P5BdYBZVFaKoROhIE+ZkWDWR4KbW ftUw== X-Gm-Message-State: APjAAAVgEvLOtmdOLxJICLYmTMlt4o02JfdemoAZ/oVWo9GRihLA8dhv kzRrDElW1GhVOfSUbgn7AJ+uYOVo+T8= X-Google-Smtp-Source: APXvYqxARiDvrinDkF0IxQnh2fo69K/lZeBYiEgmn0/VopSpl3XirwQo4YqSm7CIx5iwHfHoj927kg== X-Received: by 2002:a63:465c:: with SMTP id v28mr23572735pgk.310.1569124501770; Sat, 21 Sep 2019 20:55:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/20] exec: Use TARGET_PAGE_BITS_MIN for TLB flags Date: Sat, 21 Sep 2019 20:54:39 -0700 Message-Id: <20190922035458.14879-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::441 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These bits do not need to vary with the actual page size used by the guest. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- include/exec/cpu-all.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index d2d443c4f9..e0c8dc540c 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -317,20 +317,24 @@ CPUArchState *cpu_copy(CPUArchState *env); =20 #if !defined(CONFIG_USER_ONLY) =20 -/* Flags stored in the low bits of the TLB virtual address. These are - * defined so that fast path ram access is all zeros. +/* + * Flags stored in the low bits of the TLB virtual address. + * These are defined so that fast path ram access is all zeros. * The flags all must be between TARGET_PAGE_BITS and * maximum address alignment bit. + * + * Use TARGET_PAGE_BITS_MIN so that these bits are constant + * when TARGET_PAGE_BITS_VARY is in effect. */ /* Zero if TLB entry is valid. */ -#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS - 1)) +#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS_MIN - 1)) /* Set if TLB entry references a clean RAM page. The iotlb entry will contain the page physical address. */ -#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS - 2)) +#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS_MIN - 2)) /* Set if TLB entry is an IO callback. */ -#define TLB_MMIO (1 << (TARGET_PAGE_BITS - 3)) +#define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 3)) /* Set if TLB entry contains a watchpoint. */ -#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS - 4)) +#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4)) =20 /* Use this mask to check interception with an alignment mask * in a TCG backend. --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569124642; cv=none; d=zoho.com; s=zohoarc; b=JlbKCWiaxgaFpQiBU44m4EjUXgbzWqApz6OtJp4hDtwiXkKJNcutLesOaeNrigtPhabJHKlZxbJb62JKDNm7+OTOVi6/z9qKeDWKdb9mYNTJJbWIQ/W3gwvGIestxdEDGpLYiSJGwJjlcNJwCJpW5Xv7H/sY/nWwyCRcHka28n4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569124642; h=Content-Type: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=Znbphz4Wbz+jf1FVrRPd7yeYKp+P9bp2bimJSC5rLFA=; b=AeLt5pH2O0Drisi/hjS/mTibvZYKplOJ0SmYHkTvaDREmBdEWn8SrMjGu/Ih1AajbCd7RLgO0WxC6bwtMKA3V6xoZ9RsgBRWwoWlJBLwytOkIzibqBzo1oSBR/coweEQHAK+4Ee1/g764/QVtudPzd184BZWrQDCv+Rv3zTL5IU= 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 1569124642480451.7664966129055; Sat, 21 Sep 2019 20:57:22 -0700 (PDT) Received: from localhost ([::1]:44894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBszt-0003Pw-Cz for importer@patchew.org; Sat, 21 Sep 2019 23:57:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40784) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxm-0001Kw-0M for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxk-00084v-Gw for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:05 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:47021) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxk-00084c-AQ for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:04 -0400 Received: by mail-pg1-x543.google.com with SMTP id a3so5972490pgm.13 for ; Sat, 21 Sep 2019 20:55:04 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:02 -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=Znbphz4Wbz+jf1FVrRPd7yeYKp+P9bp2bimJSC5rLFA=; b=VHbIbLG0jV9poZAsAaMNnwZ6Eyci4TVnMSFKiHJM1K0dPaSJjGDoGSn6v8Es+tX009 2M/1w79duh4+XopXIEFfBUPAYKEiTVSwamHg82U/d5d760nJ+Vwd1RTexBRjW3TtLkua T6ewSV9mP6rxDrPsCSvgvYDphjehNGSN+RHi62v2AjFVKgJdUWGGDI/iuVWaEVnn3P0+ YNa/2PHpylcUO+0bpqrakTooz375Ph3bAkbCiGL2+7Dffp2UiY9rQfpAm3ljlezn5dFJ kHi0JsN3O+Nv8x3YjvrHQEnJzLm7+yi/UDsjwpo24eJEiCYh+nGsJoJnnDpCzxWKjn20 JDlA== 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=Znbphz4Wbz+jf1FVrRPd7yeYKp+P9bp2bimJSC5rLFA=; b=ZVXWmXvdaAGEYrAqfS7VnQpl2pC8zPHvt86fJg8aMaj7t6r/J34Bye/Styg6tEPBw7 troEeKR5sMrwoa4aalP6BVXLEOa21immk8Vg5mglu4tuP5JD+D6NKTZODm/lDxXX3+/g +C0AWeLjkPYkKjzVMjjpPLltjL3NmI1msxwOdn0OF7OkdNOqSa5rBpCcteUdU1qIb31k vr0SpNjYoXiz+7lod1iPEeaS1kcmBit3xx6mbp9Q/A5XopSKIcuBSKX0yUbRXdGIVbn0 KUEn5i9NnJ2WHckyu24GZ4SU2JjEYYayZ+TcIT4SrbDUx1lEuMe3KngZ3SII9yueOEpa /mHQ== X-Gm-Message-State: APjAAAXohsImw7goZ+oD1+PasUYndTU+viCY1PF+ytJBedZe2NLng2QS vukOMBvkzEz1nXY0kzEjQxGpjVSsBAY= X-Google-Smtp-Source: APXvYqxQJzLhMSg2pEmiRu30SQVfI5MJdiQdI1hZnLUCw9DgS6gQz+iUTLResdgWsrzzlIUTnq9jXg== X-Received: by 2002:aa7:9ddd:: with SMTP id g29mr27122349pfq.146.1569124502979; Sat, 21 Sep 2019 20:55:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/20] exec: Split out variable page size support to exec-vary.c Date: Sat, 21 Sep 2019 20:54:40 -0700 Message-Id: <20190922035458.14879-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The next patch will play a trick with "const" that will confuse the compiler about the uses of target_page_bits within exec.c. Moving everything to a new file prevents this confusion. No functional change so far. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- Makefile.target | 2 +- include/qemu-common.h | 6 +++++ exec-vary.c | 57 +++++++++++++++++++++++++++++++++++++++++++ exec.c | 34 -------------------------- 4 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 exec-vary.c diff --git a/Makefile.target b/Makefile.target index 5e916230c4..ca3d14efe1 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,7 @@ obj-y +=3D trace/ =20 ######################################################### # cpu emulator library -obj-y +=3D exec.o +obj-y +=3D exec.o exec-vary.o obj-y +=3D accel/ obj-$(CONFIG_TCG) +=3D tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-= gvec.o obj-$(CONFIG_TCG) +=3D tcg/tcg-common.o tcg/optimize.o diff --git a/include/qemu-common.h b/include/qemu-common.h index 8d84db90b0..082da59e85 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -74,6 +74,12 @@ void cpu_exec_step_atomic(CPUState *cpu); */ bool set_preferred_target_page_bits(int bits); =20 +/** + * finalize_target_page_bits: + * Commit the final value set by set_preferred_target_page_bits. + */ +void finalize_target_page_bits(void); + /** * Sends a (part of) iovec down a socket, yielding when the socket is full= , or * Receives data into a (part of) iovec from a socket, diff --git a/exec-vary.c b/exec-vary.c new file mode 100644 index 0000000000..48c0ab306c --- /dev/null +++ b/exec-vary.c @@ -0,0 +1,57 @@ +/* + * Variable page size handling + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "exec/exec-all.h" + +#ifdef TARGET_PAGE_BITS_VARY +int target_page_bits; +bool target_page_bits_decided; +#endif + +bool set_preferred_target_page_bits(int bits) +{ + /* + * The target page size is the lowest common denominator for all + * the CPUs in the system, so we can only make it smaller, never + * larger. And we can't make it smaller once we've committed to + * a particular size. + */ +#ifdef TARGET_PAGE_BITS_VARY + assert(bits >=3D TARGET_PAGE_BITS_MIN); + if (target_page_bits =3D=3D 0 || target_page_bits > bits) { + if (target_page_bits_decided) { + return false; + } + target_page_bits =3D bits; + } +#endif + return true; +} + +void finalize_target_page_bits(void) +{ +#ifdef TARGET_PAGE_BITS_VARY + if (target_page_bits =3D=3D 0) { + target_page_bits =3D TARGET_PAGE_BITS_MIN; + } + target_page_bits_decided =3D true; +#endif +} diff --git a/exec.c b/exec.c index 8b998974f8..33bd0e36c1 100644 --- a/exec.c +++ b/exec.c @@ -92,11 +92,6 @@ MemoryRegion io_mem_rom, io_mem_notdirty; static MemoryRegion io_mem_unassigned; #endif =20 -#ifdef TARGET_PAGE_BITS_VARY -int target_page_bits; -bool target_page_bits_decided; -#endif - CPUTailQ cpus =3D QTAILQ_HEAD_INITIALIZER(cpus); =20 /* current CPU in the current thread. It is only valid inside @@ -110,37 +105,8 @@ int use_icount; uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; =20 -bool set_preferred_target_page_bits(int bits) -{ - /* The target page size is the lowest common denominator for all - * the CPUs in the system, so we can only make it smaller, never - * larger. And we can't make it smaller once we've committed to - * a particular size. - */ -#ifdef TARGET_PAGE_BITS_VARY - assert(bits >=3D TARGET_PAGE_BITS_MIN); - if (target_page_bits =3D=3D 0 || target_page_bits > bits) { - if (target_page_bits_decided) { - return false; - } - target_page_bits =3D bits; - } -#endif - return true; -} - #if !defined(CONFIG_USER_ONLY) =20 -static void finalize_target_page_bits(void) -{ -#ifdef TARGET_PAGE_BITS_VARY - if (target_page_bits =3D=3D 0) { - target_page_bits =3D TARGET_PAGE_BITS_MIN; - } - target_page_bits_decided =3D true; -#endif -} - typedef struct PhysPageEntry PhysPageEntry; =20 struct PhysPageEntry { --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569124868; cv=none; d=zoho.com; s=zohoarc; b=KuLl82MLwiFzKwOrDr1rrjRSRYqXxZ/33ffkPRGSz6h+uSV7JHqDC6MNPvT+neuTcj62NCSk5rckBrsKhSWiVuApuac2aquMsNj1vGN7zhUrZbLXWlDCfe2PcUCGgqIwh4sIJXyuCXtSPrKDfLwS28Yvkpbpf/E6KnwTi/bP1lE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569124868; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=byxOPmOWUxDtiAxAlrSZ0T4d6Z5pot/AQfly4fPI+LE=; b=nMIkzV7IPzXlEzLptTX/SamyeONkBKXG0N/IGhlfPcTNdRHpmH+LoS2s010Dnfg+7uUNbKlvuzbNTQ44gunmuEKOo+RMM7Bdlmkn/yo/t7+uQb9DVZjlgiNXRd+35jt4FkyB0BEhAIowkBlwx7pzL29K8uaFaP0xzF5nrTsD70w= 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 1569124868678202.74527677540675; Sat, 21 Sep 2019 21:01:08 -0700 (PDT) Received: from localhost ([::1]:44944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt3X-0006p8-Og for importer@patchew.org; Sun, 22 Sep 2019 00:01:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40797) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxn-0001LU-7P for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxl-00085h-QH for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:07 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:42060) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxl-00085K-KX for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:05 -0400 Received: by mail-pg1-x542.google.com with SMTP id z12so5989848pgp.9 for ; Sat, 21 Sep 2019 20:55:05 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55: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; bh=byxOPmOWUxDtiAxAlrSZ0T4d6Z5pot/AQfly4fPI+LE=; b=IHq64Hpw987w/v4gQ/depF8PupqP1t18Ieyvie54MBJpTzZRG0VgxoZmaSqkYIuFR6 so8NZvhwtWEYnMJO3I2VW1rc4Ng9XO2nRBbXCvxkd/bE4RGoC5lE7c23mpJyV2mnkdpU f4qXjZsGnTNZzC1Lf3j41m6cYSgsmPx/3MaYZGPeyy12gBNFEzYTJjOhrrb8EvcDRCAA RGSHZiYFRUiG5HouPeti5AH/YFsDmf9vG1sautkZOeXaSp73Gev14YIdCLD9AOHsaZvY I7V+KfR+UJLvdPDdxKNyZaiHUm7RYcUIaFz6/hxOg7EKEgunRET32IDZyjvdue3aNtDs E1uw== 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=byxOPmOWUxDtiAxAlrSZ0T4d6Z5pot/AQfly4fPI+LE=; b=CPRV0sssA0ZCt/kJVcz90FVA1KUrb9IS0V/00c1E9wtaQPy2qWDeMoDj5Y1O5ewpH4 +U4GdXOsuMVbfM9aZrEHHayQpwGX80dGH3DcIesrLfxb7H1vWs4iMH/bYj0LJdXqAzx/ JcZQ0+2kxLmn4IT+wBVEW38c5ffNyUIYi90GsH0F9TCL7PebuKcMP+K7APpeUfjXpZMp G6HPNwRIQsYS6Yr3qipg51GA9DO4RAVp7WT8/brUFmEbe/zVlWDJez3y8tjwzy3s50Ki /K6I9+jtHAL5BnLeQuay6LmjvoTMiLTcmE2zk5hCyrDDRinbSbe/buy2JxnERY/aN3uf +MAA== X-Gm-Message-State: APjAAAV0veU+7lFM5oGgfNGYYcLjl6PkkMRFP4HbNezfaQZf04GZAqJD l7X3RKmuHglD17fplW6HxDQkRGxAb9E= X-Google-Smtp-Source: APXvYqwdYkasUAjt7wLwGAkQpq7RLmBw+FzSUFoYGU/2I0ApDfTK05npQuWnd85mlvM0wroL+rBKpQ== X-Received: by 2002:a63:5754:: with SMTP id h20mr22412937pgm.195.1569124504267; Sat, 21 Sep 2019 20:55:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/20] exec: Use const alias for TARGET_PAGE_BITS_VARY Date: Sat, 21 Sep 2019 20:54:41 -0700 Message-Id: <20190922035458.14879-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Using a variable that is declared "const" for this tells the compiler that it may read the value once and assume that it does not change across function calls. For target_page_size, this means we have only one assert per function, and one read of the variable. This reduces the size of qemu-system-aarch64 by 8k. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 10 +++++---- exec-vary.c | 46 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index e0c8dc540c..a53b761b48 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -210,10 +210,12 @@ static inline void stl_phys_notdirty(AddressSpace *as= , hwaddr addr, uint32_t val /* page related stuff */ =20 #ifdef TARGET_PAGE_BITS_VARY -extern bool target_page_bits_decided; -extern int target_page_bits; -#define TARGET_PAGE_BITS ({ assert(target_page_bits_decided); \ - target_page_bits; }) +typedef struct { + bool decided; + int bits; +} TargetPageBits; +extern const TargetPageBits target_page; +#define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS #endif diff --git a/exec-vary.c b/exec-vary.c index 48c0ab306c..67cdf57a9c 100644 --- a/exec-vary.c +++ b/exec-vary.c @@ -22,8 +22,38 @@ #include "exec/exec-all.h" =20 #ifdef TARGET_PAGE_BITS_VARY -int target_page_bits; -bool target_page_bits_decided; +/* + * We want to declare the "target_page" variable as const, which tells + * the compiler that it can cache any value that it reads across calls. + * This avoids multiple assertions and multiple reads within any one user. + * + * This works because we initialize the target_page data very early, in a + * location far removed from the functions that require the final results. + * + * This also requires that we have a non-constant symbol by which we can + * perform the actual initialization, and which forces the data to be + * allocated within writable memory. Thus "init_target_page", and we use + * that symbol exclusively in the two functions that initialize this value. + * + * The "target_page" symbol is created as an alias of "init_target_page". + */ +static TargetPageBits init_target_page; + +/* + * Note that this is *not* a redundant decl, this is the definition of + * the "target_page" symbol. The syntax for this definition requires + * the use of the extern keyword. This seems to be a GCC bug in + * either the syntax for the alias attribute or in -Wredundant-decls. + * + * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D91765 + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wredundant-decls" + +extern const TargetPageBits target_page + __attribute__((alias("init_target_page"))); + +#pragma GCC diagnostic pop #endif =20 bool set_preferred_target_page_bits(int bits) @@ -36,11 +66,11 @@ bool set_preferred_target_page_bits(int bits) */ #ifdef TARGET_PAGE_BITS_VARY assert(bits >=3D TARGET_PAGE_BITS_MIN); - if (target_page_bits =3D=3D 0 || target_page_bits > bits) { - if (target_page_bits_decided) { + if (init_target_page.bits =3D=3D 0 || init_target_page.bits > bits) { + if (init_target_page.decided) { return false; } - target_page_bits =3D bits; + init_target_page.bits =3D bits; } #endif return true; @@ -49,9 +79,9 @@ bool set_preferred_target_page_bits(int bits) void finalize_target_page_bits(void) { #ifdef TARGET_PAGE_BITS_VARY - if (target_page_bits =3D=3D 0) { - target_page_bits =3D TARGET_PAGE_BITS_MIN; + if (init_target_page.bits =3D=3D 0) { + init_target_page.bits =3D TARGET_PAGE_BITS_MIN; } - target_page_bits_decided =3D true; + init_target_page.decided =3D true; #endif } --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569124640; cv=none; d=zoho.com; s=zohoarc; b=j1ibt4cRDp2tH9DKJHMXkv/yDJ8+XzK3NiXFKjl7R789Ue2vOwaECv6NqV4W0cQkw09tF57/dD90wy+R1TY6moaEbzgos86wk/ieGu9bF+0g5YjExZtL2ZT+tns7Jo1WOo2SXsS1VKQ+/6PEpjH2NLCG5V491eAkUmf5CuoZvOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569124640; h=Content-Type: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=On6urL98+WZbXDi+CGo9wCKTkADz471arOAqlknvUss=; b=XaBk/9KSvD4ak27HyogJP7BuuQnu9gDuwmCpHyWXMZwcpqD0JzhSz7g2adjbNkOx+7YJnfezz5ExgswsiGaYz4zQrUC+dxt3RH3gnCXd9txv9HVA9DNoGSLCL2BNKDz8FoTAD7sd4PBL5Z7sgjEIwR2JFGhKU0oMIgpOARxyc6A= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569124640349228.9485276418933; Sat, 21 Sep 2019 20:57:20 -0700 (PDT) Received: from localhost ([::1]:44898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBszp-0003Ru-NU for importer@patchew.org; Sat, 21 Sep 2019 23:57:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40803) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxn-0001MM-Sg for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxm-00086B-Rq for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:07 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:41594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxm-00085u-M6 for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:06 -0400 Received: by mail-pg1-x543.google.com with SMTP id s1so4882533pgv.8 for ; Sat, 21 Sep 2019 20:55:06 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55: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=On6urL98+WZbXDi+CGo9wCKTkADz471arOAqlknvUss=; b=mzf07D+1+eSSdk4vlsWKfeYbpKYvnq/e2qA1sVpw82Lw64Axs3G5NNQxpHdGKeTiCs ubieAxUdl7rEn/Pln5AHUqHF0q/ME5UhqIHGGR90dtOY1po833be97r/S88aAT0lrAHV VeffzqjdKWnFwxAJwFhTAUjQbhJ49lzrt8BScNnN0CGD5f6iqHcW/1VV/i9yjVPsYanS pUxA5V18owr0dCw3lRWDP8htaWSiVzIgW2R+/kq+yZ6rOOGFVU9+zEvOhAAEbw2YPtKI /zPza+mUa2cJch6CVS9ald3ncJQlTF91JJsXZJPJTdYRYlzgEKD9L8vOSE2ASnbhv/YJ HH0Q== 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=On6urL98+WZbXDi+CGo9wCKTkADz471arOAqlknvUss=; b=q5L8XL+Vv1B34n1qPw6mar+TACXxIFIIE3XQ8hO+5XJnDaSnKOK0olV13DRNhQ7SBu t43f6khXE3YU7Qi08yWbe4nq8n/M/wtw5MQyAW/oog/aPv87EqCqg/BYiGfwM8P9FHvK PsyCMrRC7I9NiRIQQkFynFAfD2Opi494gTVpqfggGwba3/ds8egPfQ6FFIT1BshBUbX7 VVEZyzwCJbUe/H2Z1FiMllNmxwARDSCdTtCAD5kRDGLow7JsC/vYlp8AvC6mvJatDU8m D1jxIXQClhAcpsaYnpYuLm7YgA7ywRxVks7RL+v+9g/J11gNzQZIs69RZjFchjHxB8FO H2BA== X-Gm-Message-State: APjAAAUjhYQMo3OOKdwD68RN6ksJG6FNishG2/xswa5qCXYrhR/+j8yN LuScxNaSW/tD1RV9J8djq551vJFmrDA= X-Google-Smtp-Source: APXvYqwNHbldR76EXo5PcsHD1zO7WhEtxrI71hDHs9B6/dlaR8IMPwQC8NmOTOIYV7NI1brZT/FJJg== X-Received: by 2002:a63:5549:: with SMTP id f9mr23270702pgm.346.1569124505431; Sat, 21 Sep 2019 20:55:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/20] exec: Restrict TARGET_PAGE_BITS_VARY assert to CONFIG_DEBUG_TCG Date: Sat, 21 Sep 2019 20:54:42 -0700 Message-Id: <20190922035458.14879-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This reduces the size of a release build by about 10k. Noticably, within the tlb miss helpers. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index a53b761b48..b11ee1f711 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -215,7 +215,11 @@ typedef struct { int bits; } TargetPageBits; extern const TargetPageBits target_page; -#define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# ifdef CONFIG_DEBUG_TCG +# define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# else +# define TARGET_PAGE_BITS target_page.bits +# endif #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS #endif --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125112; cv=none; d=zoho.com; s=zohoarc; b=HSZbJ6EB/wurffMu2Oh4FjTGuR4MAYk0NYyopXk+drBNe52QEFfhaXpkTGJ1aTmK8guvTvVm0aVhkW/VxWvBBQ2LGtrWkBmph4E8VTKcEh6jHxttS970t1xXxucqJSkji0QRKtK0vBwXYK6IbaNnYOTEtDE5MhWCzZtB1BO9sqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125112; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pCxJTsjXZq8g03qIiRt5SN5kChF38n16rM3czFVAxy4=; b=e4gLX1M9QH2rOuvT4KrZGFmCTFpH2T9txv95++RXFG3CTcEfqHzhB5AVCdcacEQlnkRpTYZZX/nGhC4RjKtshBBtHQHcvu3TFobZu96EGmLR1PLXendIzvrlwMFf8b5HynmowisJ969EBfkpuXNvhkOVuTdcyBl5mOuJ7hHxeUI= 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 1569125112546172.72272434448075; Sat, 21 Sep 2019 21:05:12 -0700 (PDT) Received: from localhost ([::1]:44990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt7W-0001fz-Ue for importer@patchew.org; Sun, 22 Sep 2019 00:05:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40820) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxp-0001Og-Kj for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxo-00087I-Fp for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:09 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:35789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxo-00086q-9m for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:08 -0400 Received: by mail-pf1-x42d.google.com with SMTP id 205so7000264pfw.2 for ; Sat, 21 Sep 2019 20:55:08 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:06 -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=pCxJTsjXZq8g03qIiRt5SN5kChF38n16rM3czFVAxy4=; b=UZyXN/4HM02XXBXKBdYfIR30vcM4GkupWbmcY2LlkMUAHmmmBeT8959/HXQIQqRLvn RQSfrDkOSL0aoYG+0buntlYfATFUw43tiMPD0V6m1hN92R7L4oZelz00YLumXVqbJAPg Jjl++xhOtwhfGXX+c6KqoXfQt9lBbZNOTfQ8XYel3g5vgWopoZiudK2DvhInJUVh8w9t r2VUEct8B0QqNJBoGkvlqFs17Q+34I9M98VXvNmPkPPxCRzVyw0ELR77hhHePmDV+7kH 4OSy1xPXGl1/JmerbOv71yLbHgOQZ6cBNwSts9CGDTgnBA1PxErO5RXMs9HEDV3QjKgu Xyeg== 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=pCxJTsjXZq8g03qIiRt5SN5kChF38n16rM3czFVAxy4=; b=j1SPapy3Sfci+AbATlZZtXEG7EQkQNlHGunUQcGh/GhLB3Q6yoETTfPCEwkpqhOuKM sC37yRDxpZJ+djaT7ogyOGRQxbkG9xgjeMqzH8O0gZFJgM8ah8JWTZ2/lhui9hwc50Zd jWC6lmgl/4RRZt5D51nubqxb9/gvidvLh32FXF8ENfthmj0SRMdg1nYnI0SmF08v+QkY sXB+pjvOVDhN0d1lOtf4YTC/DqO/tIrEz4RfCXFTziTCHlzZcIAe+c6lT/cciO9fwv0q /89Odx6XDOwftX+6nv1g7W6PvB00qSWRwAAjr+d+wt4R3idplIzFZM8kA2wbjCu6F051 Yiag== X-Gm-Message-State: APjAAAXBGHrkFh37xYwzuesLFnAD0+Wsw4AJULpjVIy8OuEVHCXQ0Goi 9/5BAMUz/FuL0HEoJixrA3n2a/l7i4s= X-Google-Smtp-Source: APXvYqzwUb9mGCJ4s+e+AM/oIsOt/M4ISMekTITY0T14F2N7KzF8GEfatzpu0rx8KafBAraS0JZrlA== X-Received: by 2002:a17:90a:3b01:: with SMTP id d1mr13351237pjc.81.1569124506950; Sat, 21 Sep 2019 20:55:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/20] exec: Promote TARGET_PAGE_MASK to target_long Date: Sat, 21 Sep 2019 20:54:43 -0700 Message-Id: <20190922035458.14879-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::42d 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There are some uint64_t uses that expect TARGET_PAGE_MASK to extend for a 32-bit, so this must continue to be a signed type. Define based on TARGET_PAGE_BITS not TARGET_PAGE_SIZE; this will make a following patch more clear. This should not have a functional effect so far. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- include/exec/cpu-all.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index b11ee1f711..34d36cebca 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -225,7 +225,7 @@ extern const TargetPageBits target_page; #endif =20 #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) +#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_= PAGE_MASK) =20 /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569124851; cv=none; d=zoho.com; s=zohoarc; b=nznqqwG2MH+otfQBLbNZU5XWiJrbZqnOvyGBCrUwyRzlBfpe7Rtv21WrfI4RdbYryuAD3F8ZpNz1gkbA2FvO6PCf6LOD+V6XbLx3cj3Z9xX8I/f1123rb/PgEj+INPpBDP8TDGefSCW5XiFqJ/Qk3IpUa9M0C84cRzRjB8V3+bY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569124851; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=W4TalZMvNpabdLXEj4HQqHc5U6U5Ly8Q0gdLiyGbKsA=; b=GZU2YZHq1JNc6taSEqBi2VXH5EVyIAM6zRvdrE+vhF2JOmueSm6GD9pgg46tjGPCKjerFTVO/LqqWEgre01XCsEYTChmdjdBdPMnOlhhh5jGbDkwPHBveA6zMIVjjcBuBtu5+ydCgYS8x7BbLcglwm4bkXXBpLevKYGSYorY3P0= 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 1569124851746190.7328049577144; Sat, 21 Sep 2019 21:00:51 -0700 (PDT) Received: from localhost ([::1]:44934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt3J-0006WZ-J1 for importer@patchew.org; Sun, 22 Sep 2019 00:00:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40834) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxr-0001RP-0N for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxp-00087o-LR for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:10 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:37467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxp-00087S-Fn for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:09 -0400 Received: by mail-pf1-x42f.google.com with SMTP id y5so6991129pfo.4 for ; Sat, 21 Sep 2019 20:55:09 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:07 -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=W4TalZMvNpabdLXEj4HQqHc5U6U5Ly8Q0gdLiyGbKsA=; b=x8p780CbKob8dCvUE8xsXqi57cfTErXtuStAryUfGLUqg/cWctViWjMIT5FCgyEWMS GNZ+WzMu9NypWIRV+NZSJTeQqzQciAN85seJulHg7T0HRND2P0kZ05LDfJIu3LLVlpgf lYzE4WjfcGy+aw23zqavaHJby5kleoTv8TcEzjImuEXr0WlZaU49OQ+P3oIbxkrQwwJh 6WZreK1W92wyLgkZpsXfSjznqULoe28tEDtkBQpOkcDKMqMlxDhPiIAYmcjm29U72A2m +fUeNyJXTZgW4r13JVhKlc8NykNi+8BWvaytKJBlQ2bbipFSdX+ygRK9o7FEen6M110o HIBA== 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=W4TalZMvNpabdLXEj4HQqHc5U6U5Ly8Q0gdLiyGbKsA=; b=mjTOw1Okb6uEOcwRYTCBZSDptKqA+P3kNwExtI235zTtIQtAhl6cgm0iFVgAuyEOGw JKTiwhSO+OSb6l8YDqYkIXV6Ae44izLA7sobKfXvkn1WTlCPFh7apqoF034gBkQutrrK YZ3aPvCkRXCgi7fQPwRaktvFd/4ohKLqm+FLW6+iFtQoC5joEZPUdDW9RteBeQUuz3J0 pEcRKgRMpxzvXSucDipXVSd9Rt2nT2KqSVgU9ZBFXIoHbJng+6tv31PW45ouAMhIGdVg tiW0KAKt108iG2A/fiPS9w/SNUpcPpdSBJW9hqpwDTNoYS4YWpE38mYp0cA2NCcuV/qv aTfQ== X-Gm-Message-State: APjAAAVLzcUdztQJn90Zg+WH7gKjotXcrazieon99cR/snNvSPVoNVfj y+nGwHC0XoFnHoRNMTzdUCaxxNYIszY= X-Google-Smtp-Source: APXvYqzkfAToL0YdiMVuFTu0prnaQvypNNkX/4KkPHPU47ontsbSZNFI5HODLJKzMdB8sVnbkhhFwQ== X-Received: by 2002:a63:724e:: with SMTP id c14mr23828003pgn.120.1569124508144; Sat, 21 Sep 2019 20:55:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/20] exec: Tidy TARGET_PAGE_ALIGN Date: Sat, 21 Sep 2019 20:54:44 -0700 Message-Id: <20190922035458.14879-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::42f 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use TARGET_PAGE_MASK twice instead of TARGET_PAGE_SIZE once. This is functionally identical, but will help a following patch. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- include/exec/cpu-all.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 34d36cebca..5246770271 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -226,7 +226,8 @@ extern const TargetPageBits target_page; =20 #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) #define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_= PAGE_MASK) +#define TARGET_PAGE_ALIGN(addr) \ + (((addr) + ~TARGET_PAGE_MASK) & TARGET_PAGE_MASK) =20 /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even * when intptr_t is 32-bit and we are aligning a long long. --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569124851; cv=none; d=zoho.com; s=zohoarc; b=Fypm9ojJmWVH/gPwK+QPqLmqUyYBoarq1TMfqprQzWYQvn4tuovnETF8UTJ12Ed4Kb5PfNoXSWK620/ed+57RXpZPhVLEbM89F0JrWAXwRz/iUywJU/ObWwdvTLl/ru2WM6Ec0KSLphWuIQV9+o3ZYssGyJVUDPWyxXMTXdMqcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569124851; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=FsCp0gCrwtqGaCEDQ93XosqgirYhBXr/1xdf8PdGGas=; b=WvZtgNZewWFfQYqJ4+sODA0DR3aO1Muq31A59Is298qm3wjq3zYviFRdbDFW8KYQ4k4aS3ZbW666DpMDw3ZYCjVPc/hOcqek0QSkM+dQFPygGFKWgS3PvpVK1QWWBZa1i19qG/n9vqWafM0EpC/cvQk1BCc0p8nP+9Boz0pm5fo= 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 1569124851643537.3008689401701; Sat, 21 Sep 2019 21:00:51 -0700 (PDT) Received: from localhost ([::1]:44930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt3I-0006W7-01 for importer@patchew.org; Sun, 22 Sep 2019 00:00:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40844) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxs-0001UX-4E for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxq-0008Aa-QW for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:11 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:42061) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxq-000895-Fr for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:10 -0400 Received: by mail-pg1-x543.google.com with SMTP id z12so5989896pgp.9 for ; Sat, 21 Sep 2019 20:55:10 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:08 -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=FsCp0gCrwtqGaCEDQ93XosqgirYhBXr/1xdf8PdGGas=; b=PlhE/CzcglvYxaWY5KpLAyLbBtSarBV8kHwCZKVGE47A8yZagFzO7/CSas0XgIpSF5 VcpP5cKSlqKYAyNw9y/5vTrSZPWYaeZCexaCvCpVI/+sbZGAcBaPw7Ng4l+R0e7vedPE WbClDOtahs9rA1f1fFz87Y0UN/muG9q+3b9MkE87Z6sDlq9UErRN6fHDGq26cLchYMBC yXc/USUKBOhG6raPS5uhzR7cDzi+hRKB2rYAJCYxK9++Pq3Pe82naWHsD0Azudcht1Xr O4l+xGa/sakos4M0FcG0KsyaMZbdIZbOc6ecEEjtI51lJFL4g9OScv7onBlVC1b6f5OL lDRw== 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=FsCp0gCrwtqGaCEDQ93XosqgirYhBXr/1xdf8PdGGas=; b=VW5J0BuDfd9c/d8hMSsqevaWdXq1ak224SK+EQxdvbrYv+K78UxikiPez8HpoSNh3w 5OwZKrGFEbpyuUXfEF4TXefMMb8BWi1JyB0TCy7oQmqVb82T5Hn99cXwbPxEOkD3VjvZ Gkct+LdAKMAUcJ0oE0N/ZMXhSTR43elVIE81MA9eZHQRcxp9tKolrywteHf7INsYE56v JH6lPVkt40g9JN6DaM19hSpOjnDyF3Olg4fGNA27gXoXXGMwbM/NMApN1+aWIzEyKADK V/NGIo1ApjC0N3Sb85Uyq4YhNjDPc0n0gdtVKPOwoDPDNg/cu/sOyOS8N+06krfIxhn/ 9sBg== X-Gm-Message-State: APjAAAUpAJPDcujUgqHgG7T4saLLbt2fr1aT/xRVFgu1RVMjm8rfbxK+ L+Y2kx9B2Yrvo9VY1ppbYrUALfLbBjY= X-Google-Smtp-Source: APXvYqz8G/ejmhZgF83MNaofzoCabOX/1pPJMgm0el6rkBH/hQ2FQEGTUFIeFByG6p2X95fx1z7cYQ== X-Received: by 2002:a63:dd0a:: with SMTP id t10mr23127705pgg.354.1569124509265; Sat, 21 Sep 2019 20:55:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/20] exec: Cache TARGET_PAGE_MASK for TARGET_PAGE_BITS_VARY Date: Sat, 21 Sep 2019 20:54:45 -0700 Message-Id: <20190922035458.14879-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::543 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This eliminates a set of runtime shifts. It turns out that we require TARGET_PAGE_MASK more often than TARGET_PAGE_SIZE, so redefine TARGET_PAGE_SIZE based on TARGET_PAGE_MASK instead of the other way around. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- include/exec/cpu-all.h | 8 ++++++-- exec-vary.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 5246770271..2db73c7a27 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -213,19 +213,23 @@ static inline void stl_phys_notdirty(AddressSpace *as= , hwaddr addr, uint32_t val typedef struct { bool decided; int bits; + target_long mask; } TargetPageBits; extern const TargetPageBits target_page; # ifdef CONFIG_DEBUG_TCG # define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# define TARGET_PAGE_MASK (assert(target_page.decided), target_page.mask) # else # define TARGET_PAGE_BITS target_page.bits +# define TARGET_PAGE_MASK target_page.mask # endif +# define TARGET_PAGE_SIZE ((int)-TARGET_PAGE_MASK) #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS +#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) +#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #endif =20 -#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #define TARGET_PAGE_ALIGN(addr) \ (((addr) + ~TARGET_PAGE_MASK) & TARGET_PAGE_MASK) =20 diff --git a/exec-vary.c b/exec-vary.c index 67cdf57a9c..26daf281f2 100644 --- a/exec-vary.c +++ b/exec-vary.c @@ -83,5 +83,6 @@ void finalize_target_page_bits(void) init_target_page.bits =3D TARGET_PAGE_BITS_MIN; } init_target_page.decided =3D true; + init_target_page.mask =3D (target_long)-1 << init_target_page.bits; #endif } --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125096; cv=none; d=zoho.com; s=zohoarc; b=AdwrEtcy+AAmYou6nMO1wAIDd+TW6c0O06FjxGB3l5IITr+NyqVyZAUaYa6eyNXryKYEh+5BtRaPv920atmjSPlIei903LE145EQ7DBEOYS8yu99AmGPrk5jC4hFAiXVEELBy9tCzZ3Ey7dGxmzkkgdhDKlQk5zpMc8LQ1igzUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125096; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GvMaV7tcHk1BMJ7VP3GkIN7btKhgbcJH5l/u+8AvH70=; b=enFpbyLOV08G/rUUWVh94fUXWnxmCfAHrr6z4q1+psseSGT2Uveslfk0grQTIH52GhIgKpf+mK2hwenhWUBgl9/cI6QcA9YoOwHKqH1rFEZN3IoGzCi+t+EZwIW8gB6ym8ZP3bZev7S4V0caoVZ1rVEcCzdRQ3R0CBVsjPf/k1M= 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 1569125096325181.61721285811439; Sat, 21 Sep 2019 21:04:56 -0700 (PDT) Received: from localhost ([::1]:44982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt7D-0001JT-TD for importer@patchew.org; Sun, 22 Sep 2019 00:04:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40856) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxt-0001Xl-FS for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxs-0008DV-5W for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:13 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:34721) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxr-0008CG-Vd for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:12 -0400 Received: by mail-pf1-x430.google.com with SMTP id b128so7003121pfa.1 for ; Sat, 21 Sep 2019 20:55:11 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:09 -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=GvMaV7tcHk1BMJ7VP3GkIN7btKhgbcJH5l/u+8AvH70=; b=cj5ggUHidfOL/BT0sd8EjORAvUhNGdFPkVx2xconxgmgFbD4Yq2vrE3tkMXHaqr6mr 5qlBuqLKALdb8ir71i5e/sWUEeoDbN+JDorpcmBdp+LOZ3jaCkCPQDLNHgCizD/3cmum 49XbqcwUFgDPdXOLS9VC4U1NwXBTOJCj86O1FQVVyH36QhdO0a57NE0RclQacTDz6oXi For1qR7H86kTrKEedWbKfxwpGPUD+dFLwNrrSUakEjhSbkW/0I4jnZp749idp0Fm9toZ Ko42D+HzMhsGD2N1wIfWFdj2rBs7qVueqZ+uP29R8ISboI16dQxZr1ZU/ZQxd3nfAkqg qUnQ== 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=GvMaV7tcHk1BMJ7VP3GkIN7btKhgbcJH5l/u+8AvH70=; b=ZW95F0H3NJk8XGlLO9O+D58Nr47P6YmzNcvKEv7tOgcGr0DL0clRLwx8tDBZMjUSJ8 a4wibNksTwBJV32PP9DCFEiIbQtKNCGaRoNmXlRk/U4y64utGxlYSd9RZqdQDVxbxTpp zf1NG1TunT+YGATbT5apYO//UgPJpwJeK7JCV0TfOLZO3ftTTwygp2J2PFO5HXMx+r19 bQ0WmlVn0FdA2ym6whgmg1DLfWbJLbTwf8moLh2vNM59Ow8JXZ+xhFGG2jhhDrrPdBev 7DOf8oyNEWqm9JOr62IRTSfZyPBowzAUN47Z5EkIyrnrGMQxekIOr0sTKzI2CLxAQNrq L25Q== X-Gm-Message-State: APjAAAX5Q3N7k2cAd2eaaug08115aLlcS4aJpp5E53+dUpSGvTsTdykv +zz33HfBZ1jXY64Dd+dwbvrLxHmk0SA= X-Google-Smtp-Source: APXvYqxHUh+f72AyLcktyKv6xTSIWIZZeItBfXl9DtXimvcLPvAuyZj1Agfvt5PSrMSzsjX2S1MzmA== X-Received: by 2002:a17:90a:e38b:: with SMTP id b11mr13329399pjz.138.1569124510414; Sat, 21 Sep 2019 20:55:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/20] cputlb: Disable __always_inline__ without optimization Date: Sat, 21 Sep 2019 20:54:46 -0700 Message-Id: <20190922035458.14879-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::430 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This forced inlining can result in missing symbols, which makes a debugging build harder to follow. Reviewed-by: David Hildenbrand Reported-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/compiler.h | 11 +++++++++++ accel/tcg/cputlb.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 09fc44cca4..d6d400c523 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -170,6 +170,17 @@ # define QEMU_NONSTRING #endif =20 +/* + * Forced inlining may be desired to encourage constant propagation + * of function parameters. However, it can also make debugging harder, + * so disable it for a non-optimizing build. + */ +#if defined(__OPTIMIZE__) && __has_attribute(always_inline) +#define QEMU_ALWAYS_INLINE __attribute__((always_inline)) +#else +#define QEMU_ALWAYS_INLINE +#endif + /* Implement C11 _Generic via GCC builtins. Example: * * QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index abae79650c..2222b87764 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1281,7 +1281,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, tar= get_ulong addr, typedef uint64_t FullLoadHelper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr); =20 -static inline uint64_t __attribute__((always_inline)) +static inline uint64_t QEMU_ALWAYS_INLINE load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op, bool code_read, FullLoadHelper *full_load) @@ -1530,7 +1530,7 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env= , target_ulong addr, * Store Helpers */ =20 -static inline void __attribute__((always_inline)) +static inline void QEMU_ALWAYS_INLINE store_helper(CPUArchState *env, target_ulong addr, uint64_t val, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op) { --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125252; cv=none; d=zoho.com; s=zohoarc; b=kYHgcrkljqodWFq6fKZqZnQmKxMfFhqzzULViwD7gbzriMVS8W6ndrqcwIAcWZB6H1hg5hzkKc6symtyX8I/bNIuL99hvfiFBJ1AR+biGx+Jzkz1Ux0/j/+9RXGjVjiJdZl0boA+eOITflf5TV0vA727AC2EVeWaDojk8+R0a84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125252; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3cfrqeC7LyJB/ROXN1SmwKtiOawGwvTqMSrbdq/eHoM=; b=eVJaydWm0qYhQZWlxXDec+ee8vfTqpc5KfZQZOGBq8/nl/Fa6cYW0NAKLaAzoEV5YAO/UtTe6W16u4OGrXjS8NKwdjnAA3aFWRMhvtYnRoaozR7vXdZYIJ1xr/RB3L0GADYpHfxyrHRtVaOHqNmgE1xZTn1ZS4dM+HmZQYW5lvg= 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 1569125252693493.51334806843386; Sat, 21 Sep 2019 21:07:32 -0700 (PDT) Received: from localhost ([::1]:45018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt9l-0004DH-E0 for importer@patchew.org; Sun, 22 Sep 2019 00:07:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40878) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxw-0001eP-R8 for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxu-0008Fd-Nh for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:16 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:42062) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxt-0008EV-FV for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:14 -0400 Received: by mail-pg1-x544.google.com with SMTP id z12so5989922pgp.9 for ; Sat, 21 Sep 2019 20:55:13 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:10 -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=3cfrqeC7LyJB/ROXN1SmwKtiOawGwvTqMSrbdq/eHoM=; b=PBeDq6Ls/F/boMYsIYfss/erPY1724FKZu6hXXKXlQRwzLgD54rjLIFwLrOAyDcu8j /0tkeVBD2xtYJuhW/v+hRYZJ0xCIr1eJRG6pOluPXixVNUH3sarXb/9ihh9dWvwo9IyQ TyIk6BeSY6J3WexpEmMIwwWtnt8O1CR/tgTQgARXqwY7AU6+jHuz6L8AMdjWdMdmTLS/ Hf8hpmbZBIRJdMUrDLTtK1SGhV3BjMJBgTAy1ZinKqUuvaAmyenTrs1E88ciXgzAc5zM HttvQLR8gXc/oIh8myd03Ed/iUOpcIlYxWtkwtQL43kYdyzpv0r/EFuam1D9p957OTM0 W2xQ== 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=3cfrqeC7LyJB/ROXN1SmwKtiOawGwvTqMSrbdq/eHoM=; b=AMDXAn6hVvIZG0LWf8HUUXJXAQ+/TnHISfC1isqhyfvpd4A0hg0pEd6ZsOPQcqvmqP glMDKjPL25pAUzKU4IcIJRCPpGYVm2IjVElHKTuwHHpsAgz9gZgkAZB+C82ZaoffteTH SILF1uh12JHeEteYH4l27SD66l6XtTxpZJQqbrKXvtjTrFkk0jKLb4hTaMFCAOsRHiK+ c3RxA+bspvssA1QYr53J4FmBA+p6CdVvBghsb8q95gTJfLm91JYOeimEcPt58Gf0gdJE aBgk/nP3YPwCyLZNQyO/QEtfW7XT0dYxi1NMllm+Ld4f2qXMX+RnMa4P6FILix3uwrfa j2ug== X-Gm-Message-State: APjAAAXSVuLeGVKzhXSgZtS7BQ82hvdC4vMBKOUU1ZUaDzLAqbuzJapk lpfoTO0pkg85Qiq0O9kRRYvO5xekZ48= X-Google-Smtp-Source: APXvYqwAXKeVKqnGvLM7mIN/Am3Etiz9ws5dMJtSzQuDnf7zWIDdADIOEh6cDx3QTooJmTDAFHWSCg== X-Received: by 2002:a62:1cf:: with SMTP id 198mr27231377pfb.31.1569124511891; Sat, 21 Sep 2019 20:55:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/20] cputlb: Replace switches in load/store_helper with callback Date: Sat, 21 Sep 2019 20:54:47 -0700 Message-Id: <20190922035458.14879-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::544 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a function parameter to perform the actual load/store to ram. With optimization, this results in identical code. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/tcg/cputlb.c | 159 +++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 76 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 2222b87764..b4a63d3928 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1280,11 +1280,38 @@ static void *atomic_mmu_lookup(CPUArchState *env, t= arget_ulong addr, =20 typedef uint64_t FullLoadHelper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr); +typedef uint64_t LoadHelper(const void *); + +/* Wrap the unaligned load helpers to that they have a common signature. = */ +static inline uint64_t wrap_ldub(const void *haddr) +{ + return ldub_p(haddr); +} + +static inline uint64_t wrap_lduw_be(const void *haddr) +{ + return lduw_be_p(haddr); +} + +static inline uint64_t wrap_lduw_le(const void *haddr) +{ + return lduw_le_p(haddr); +} + +static inline uint64_t wrap_ldul_be(const void *haddr) +{ + return (uint32_t)ldl_be_p(haddr); +} + +static inline uint64_t wrap_ldul_le(const void *haddr) +{ + return (uint32_t)ldl_le_p(haddr); +} =20 static inline uint64_t QEMU_ALWAYS_INLINE load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op, bool code_read, - FullLoadHelper *full_load) + FullLoadHelper *full_load, LoadHelper *direct) { uintptr_t mmu_idx =3D get_mmuidx(oi); uintptr_t index =3D tlb_index(env, mmu_idx, addr); @@ -1373,33 +1400,7 @@ load_helper(CPUArchState *env, target_ulong addr, TC= GMemOpIdx oi, =20 do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); - switch (op) { - case MO_UB: - res =3D ldub_p(haddr); - break; - case MO_BEUW: - res =3D lduw_be_p(haddr); - break; - case MO_LEUW: - res =3D lduw_le_p(haddr); - break; - case MO_BEUL: - res =3D (uint32_t)ldl_be_p(haddr); - break; - case MO_LEUL: - res =3D (uint32_t)ldl_le_p(haddr); - break; - case MO_BEQ: - res =3D ldq_be_p(haddr); - break; - case MO_LEQ: - res =3D ldq_le_p(haddr); - break; - default: - g_assert_not_reached(); - } - - return res; + return direct(haddr); } =20 /* @@ -1415,7 +1416,8 @@ load_helper(CPUArchState *env, target_ulong addr, TCG= MemOpIdx oi, static uint64_t full_ldub_mmu(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { - return load_helper(env, addr, oi, retaddr, MO_UB, false, full_ldub_mmu= ); + return load_helper(env, addr, oi, retaddr, MO_UB, false, + full_ldub_mmu, wrap_ldub); } =20 tcg_target_ulong helper_ret_ldub_mmu(CPUArchState *env, target_ulong addr, @@ -1428,7 +1430,7 @@ static uint64_t full_le_lduw_mmu(CPUArchState *env, t= arget_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEUW, false, - full_le_lduw_mmu); + full_le_lduw_mmu, wrap_lduw_le); } =20 tcg_target_ulong helper_le_lduw_mmu(CPUArchState *env, target_ulong addr, @@ -1441,7 +1443,7 @@ static uint64_t full_be_lduw_mmu(CPUArchState *env, t= arget_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEUW, false, - full_be_lduw_mmu); + full_be_lduw_mmu, wrap_lduw_be); } =20 tcg_target_ulong helper_be_lduw_mmu(CPUArchState *env, target_ulong addr, @@ -1454,7 +1456,7 @@ static uint64_t full_le_ldul_mmu(CPUArchState *env, t= arget_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEUL, false, - full_le_ldul_mmu); + full_le_ldul_mmu, wrap_ldul_le); } =20 tcg_target_ulong helper_le_ldul_mmu(CPUArchState *env, target_ulong addr, @@ -1467,7 +1469,7 @@ static uint64_t full_be_ldul_mmu(CPUArchState *env, t= arget_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEUL, false, - full_be_ldul_mmu); + full_be_ldul_mmu, wrap_ldul_be); } =20 tcg_target_ulong helper_be_ldul_mmu(CPUArchState *env, target_ulong addr, @@ -1480,14 +1482,14 @@ uint64_t helper_le_ldq_mmu(CPUArchState *env, targe= t_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEQ, false, - helper_le_ldq_mmu); + helper_le_ldq_mmu, ldq_le_p); } =20 uint64_t helper_be_ldq_mmu(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEQ, false, - helper_be_ldq_mmu); + helper_be_ldq_mmu, ldq_be_p); } =20 /* @@ -1530,9 +1532,38 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *en= v, target_ulong addr, * Store Helpers */ =20 +typedef void StoreHelper(void *, uint64_t); + +/* Wrap the unaligned store helpers to that they have a common signature. = */ +static inline void wrap_stb(void *haddr, uint64_t val) +{ + stb_p(haddr, val); +} + +static inline void wrap_stw_be(void *haddr, uint64_t val) +{ + stw_be_p(haddr, val); +} + +static inline void wrap_stw_le(void *haddr, uint64_t val) +{ + stw_le_p(haddr, val); +} + +static inline void wrap_stl_be(void *haddr, uint64_t val) +{ + stl_be_p(haddr, val); +} + +static inline void wrap_stl_le(void *haddr, uint64_t val) +{ + stl_le_p(haddr, val); +} + static inline void QEMU_ALWAYS_INLINE store_helper(CPUArchState *env, target_ulong addr, uint64_t val, - TCGMemOpIdx oi, uintptr_t retaddr, MemOp op) + TCGMemOpIdx oi, uintptr_t retaddr, MemOp op, + StoreHelper *direct) { uintptr_t mmu_idx =3D get_mmuidx(oi); uintptr_t index =3D tlb_index(env, mmu_idx, addr); @@ -1657,74 +1688,49 @@ store_helper(CPUArchState *env, target_ulong addr, = uint64_t val, =20 do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); - switch (op) { - case MO_UB: - stb_p(haddr, val); - break; - case MO_BEUW: - stw_be_p(haddr, val); - break; - case MO_LEUW: - stw_le_p(haddr, val); - break; - case MO_BEUL: - stl_be_p(haddr, val); - break; - case MO_LEUL: - stl_le_p(haddr, val); - break; - case MO_BEQ: - stq_be_p(haddr, val); - break; - case MO_LEQ: - stq_le_p(haddr, val); - break; - default: - g_assert_not_reached(); - break; - } + direct(haddr, val); } =20 void helper_ret_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_UB); + store_helper(env, addr, val, oi, retaddr, MO_UB, wrap_stb); } =20 void helper_le_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_LEUW); + store_helper(env, addr, val, oi, retaddr, MO_LEUW, wrap_stw_le); } =20 void helper_be_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_BEUW); + store_helper(env, addr, val, oi, retaddr, MO_BEUW, wrap_stw_be); } =20 void helper_le_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_LEUL); + store_helper(env, addr, val, oi, retaddr, MO_LEUL, wrap_stl_le); } =20 void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_BEUL); + store_helper(env, addr, val, oi, retaddr, MO_BEUL, wrap_stl_be); } =20 void helper_le_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_LEQ); + store_helper(env, addr, val, oi, retaddr, MO_LEQ, stq_le_p); } =20 void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_BEQ); + store_helper(env, addr, val, oi, retaddr, MO_BEQ, stq_be_p); } =20 /* First set of helpers allows passing in of OI and RETADDR. This makes @@ -1789,7 +1795,8 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulon= g addr, uint64_t val, static uint64_t full_ldub_cmmu(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { - return load_helper(env, addr, oi, retaddr, MO_8, true, full_ldub_cmmu); + return load_helper(env, addr, oi, retaddr, MO_8, true, + full_ldub_cmmu, wrap_ldub); } =20 uint8_t helper_ret_ldb_cmmu(CPUArchState *env, target_ulong addr, @@ -1802,7 +1809,7 @@ static uint64_t full_le_lduw_cmmu(CPUArchState *env, = target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEUW, true, - full_le_lduw_cmmu); + full_le_lduw_cmmu, wrap_lduw_le); } =20 uint16_t helper_le_ldw_cmmu(CPUArchState *env, target_ulong addr, @@ -1815,7 +1822,7 @@ static uint64_t full_be_lduw_cmmu(CPUArchState *env, = target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEUW, true, - full_be_lduw_cmmu); + full_be_lduw_cmmu, wrap_lduw_be); } =20 uint16_t helper_be_ldw_cmmu(CPUArchState *env, target_ulong addr, @@ -1828,7 +1835,7 @@ static uint64_t full_le_ldul_cmmu(CPUArchState *env, = target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEUL, true, - full_le_ldul_cmmu); + full_le_ldul_cmmu, wrap_ldul_le); } =20 uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr, @@ -1841,7 +1848,7 @@ static uint64_t full_be_ldul_cmmu(CPUArchState *env, = target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEUL, true, - full_be_ldul_cmmu); + full_be_ldul_cmmu, wrap_ldul_be); } =20 uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr, @@ -1854,12 +1861,12 @@ uint64_t helper_le_ldq_cmmu(CPUArchState *env, targ= et_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEQ, true, - helper_le_ldq_cmmu); + helper_le_ldq_cmmu, ldq_le_p); } =20 uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEQ, true, - helper_be_ldq_cmmu); + helper_be_ldq_cmmu, ldq_be_p); } --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125096; cv=none; d=zoho.com; s=zohoarc; b=PqCb/03ub+boKHoPyOD/wlOcTvx6p6Kk2BcxjZp8//Fuc+PVMdhM2JvnDePj+wu+QbEBAg8mqa8ie9fU33WJd8O9hyO88/F8vxw7z7TiqTQUiI5VS8AVjWTnn8FbIaOc0PoEzgu6SIeuVSuDMA+eDtLjHJcLNIRkmvOMqeO+1nE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125096; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8IxzWXREzB4fnRwv6M1K8EmomnmZg0bbtL//H90zvk0=; b=Bjp7yK0FroM71Mos3r2zLBmeljVLLANLNP1Kk1hszpoK/7hzJPjQdE0QE5fOJVwQ/cqpkpzLlPVi2gSccgPO70SxggX4PGU9IQSrZqAE6xW2QHBOyF2Bpa1n+U7lm3h2AKjEsWS1OCab61uMq9Go030a9cncAWi6iOxmsLzrpqc= 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 1569125096395783.6326730901337; Sat, 21 Sep 2019 21:04:56 -0700 (PDT) Received: from localhost ([::1]:44986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt7E-0001KF-4V for importer@patchew.org; Sun, 22 Sep 2019 00:04:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40890) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxx-0001gN-RE for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxv-0008Fx-6T for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:17 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:35764) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxu-0008FO-TI for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:15 -0400 Received: by mail-pf1-x444.google.com with SMTP id 205so7000323pfw.2 for ; Sat, 21 Sep 2019 20:55:14 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:12 -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=8IxzWXREzB4fnRwv6M1K8EmomnmZg0bbtL//H90zvk0=; b=H4/10l/Rnu8Kc5pCarZ3or78vEp3qWnnDbjl3YL5YONJjmpHgJdxZT2fqP2SisLpQW LBh+9O81Zg4dukeFfM0iyM0CD8YSskUksXu+oDpBEhGkSr0VdoKC5DU9sIO3qjGjh66U lbHW2lD0xBuBD2D8fCeDfOiZznwnrfGVZ2Qzl1/8xpP8kjjndDGJNWnyqMHLuJ4mF4iO wIiCzqvGXPAViccr2gHI1WHi2ZxY4Jm4gqz9JNvkYmuAM7S20Z1f5nPz1njXr8SstlUp Lyw1US6Z9CY4NmRukqooYLR3x6iiNFGF7AUjeV8Vv5yHWX/ImMxbwEOumV+4m/vI9JDS 7Rog== 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=8IxzWXREzB4fnRwv6M1K8EmomnmZg0bbtL//H90zvk0=; b=GiZFZjVK0kglkNJaNmCXOwuqiYKlVVuuGVFg4rxu2VnjApalFgxbC+XsvMXFLXqHvw pJbk1h/QoNnYvm6FPsDAaXs3rkapSlhxcauFrs1HIzdLD2yRxWAc4YgN4gGDo7acNkkl zsf2JhJIA1/vT8AGApB9WsEvoCqJAckxklDsjIPn4aCIGcyzPDJYE2BjE30JliXNZ73c 8LQWeGfzXrRs2XFTMPNFEM0324ZVreTFyrzyayCbnZbUCQWqNM3hRpmk1g9CEyfmtl7Z B9IoM2AlQvSEDrrXU6cLQ90o0O3j9hEySclHO7y+t2BcPm6GaELTbvXoLtzDMWWgFZj3 3Erw== X-Gm-Message-State: APjAAAUJhpbljzkqpcgDQ28rIh1wFNdzuMGSYLkDc8XAAuHEpVTyC/XV ZPst5Pcgie1z9AIcjUV5Iwi2MQikfwU= X-Google-Smtp-Source: APXvYqw2UIYSX5oUa+49ZJ1tDqBlXskXt8L0Hph82wRtPW8z3u7dDmpFEbEZaDSdkgrONMPJLvyeWw== X-Received: by 2002:a63:ef58:: with SMTP id c24mr23719289pgk.207.1569124513401; Sat, 21 Sep 2019 20:55:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/20] cputlb: Introduce TLB_BSWAP Date: Sat, 21 Sep 2019 20:54:48 -0700 Message-Id: <20190922035458.14879-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::444 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Handle bswap on ram directly in load/store_helper. This fixes a bug with the previous implementation in that one cannot use the I/O path for RAM. Fixes: a26fc6f5152b47f1 Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- include/exec/cpu-all.h | 4 +- accel/tcg/cputlb.c | 108 +++++++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 2db73c7a27..1ebd1b59ab 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -346,12 +346,14 @@ CPUArchState *cpu_copy(CPUArchState *env); #define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 3)) /* Set if TLB entry contains a watchpoint. */ #define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4)) +/* Set if TLB entry requires byte swap. */ +#define TLB_BSWAP (1 << (TARGET_PAGE_BITS_MIN - 5)) =20 /* Use this mask to check interception with an alignment mask * in a TCG backend. */ #define TLB_FLAGS_MASK \ - (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT) + (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT | TLB_BSW= AP) =20 /** * tlb_hit_page: return true if page aligned @addr is a hit against the diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b4a63d3928..cb603917a2 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -737,8 +737,7 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulon= g vaddr, address |=3D TLB_INVALID_MASK; } if (attrs.byte_swap) { - /* Force the access through the I/O slow path. */ - address |=3D TLB_MMIO; + address |=3D TLB_BSWAP; } if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) { @@ -901,10 +900,6 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEn= try *iotlbentry, bool locked =3D false; MemTxResult r; =20 - if (iotlbentry->attrs.byte_swap) { - op ^=3D MO_BSWAP; - } - section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -947,10 +942,6 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry= *iotlbentry, bool locked =3D false; MemTxResult r; =20 - if (iotlbentry->attrs.byte_swap) { - op ^=3D MO_BSWAP; - } - section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -1133,8 +1124,8 @@ void *probe_access(CPUArchState *env, target_ulong ad= dr, int size, wp_access, retaddr); } =20 - if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO)) { - /* I/O access */ + /* Reject I/O access, or other required slow-path. */ + if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO | TLB_BSWAP)) { return NULL; } =20 @@ -1311,7 +1302,8 @@ static inline uint64_t wrap_ldul_le(const void *haddr) static inline uint64_t QEMU_ALWAYS_INLINE load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op, bool code_read, - FullLoadHelper *full_load, LoadHelper *direct) + FullLoadHelper *full_load, LoadHelper *direct, + LoadHelper *direct_swap) { uintptr_t mmu_idx =3D get_mmuidx(oi); uintptr_t index =3D tlb_index(env, mmu_idx, addr); @@ -1361,17 +1353,21 @@ load_helper(CPUArchState *env, target_ulong addr, T= CGMemOpIdx oi, /* On watchpoint hit, this will longjmp out. */ cpu_check_watchpoint(env_cpu(env), addr, size, iotlbentry->attrs, BP_MEM_READ, retaddr); - - /* The backing page may or may not require I/O. */ - tlb_addr &=3D ~TLB_WATCHPOINT; - if ((tlb_addr & ~TARGET_PAGE_MASK) =3D=3D 0) { - goto do_aligned_access; - } } =20 /* Handle I/O access. */ - return io_readx(env, iotlbentry, mmu_idx, addr, - retaddr, access_type, op); + if (likely(tlb_addr & TLB_MMIO)) { + return io_readx(env, iotlbentry, mmu_idx, addr, + retaddr, access_type, + op ^ (tlb_addr & TLB_BSWAP ? MO_BSWAP : 0)); + } + + haddr =3D (void *)((uintptr_t)addr + entry->addend); + + if (unlikely(tlb_addr & TLB_BSWAP)) { + return direct_swap(haddr); + } + return direct(haddr); } =20 /* Handle slow unaligned access (it spans two pages or IO). */ @@ -1398,7 +1394,6 @@ load_helper(CPUArchState *env, target_ulong addr, TCG= MemOpIdx oi, return res & MAKE_64BIT_MASK(0, size * 8); } =20 - do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); return direct(haddr); } @@ -1417,7 +1412,7 @@ static uint64_t full_ldub_mmu(CPUArchState *env, targ= et_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_UB, false, - full_ldub_mmu, wrap_ldub); + full_ldub_mmu, wrap_ldub, wrap_ldub); } =20 tcg_target_ulong helper_ret_ldub_mmu(CPUArchState *env, target_ulong addr, @@ -1430,7 +1425,7 @@ static uint64_t full_le_lduw_mmu(CPUArchState *env, t= arget_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEUW, false, - full_le_lduw_mmu, wrap_lduw_le); + full_le_lduw_mmu, wrap_lduw_le, wrap_lduw_be); } =20 tcg_target_ulong helper_le_lduw_mmu(CPUArchState *env, target_ulong addr, @@ -1443,7 +1438,7 @@ static uint64_t full_be_lduw_mmu(CPUArchState *env, t= arget_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEUW, false, - full_be_lduw_mmu, wrap_lduw_be); + full_be_lduw_mmu, wrap_lduw_be, wrap_lduw_le); } =20 tcg_target_ulong helper_be_lduw_mmu(CPUArchState *env, target_ulong addr, @@ -1456,7 +1451,7 @@ static uint64_t full_le_ldul_mmu(CPUArchState *env, t= arget_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEUL, false, - full_le_ldul_mmu, wrap_ldul_le); + full_le_ldul_mmu, wrap_ldul_le, wrap_ldul_be); } =20 tcg_target_ulong helper_le_ldul_mmu(CPUArchState *env, target_ulong addr, @@ -1469,7 +1464,7 @@ static uint64_t full_be_ldul_mmu(CPUArchState *env, t= arget_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEUL, false, - full_be_ldul_mmu, wrap_ldul_be); + full_be_ldul_mmu, wrap_ldul_be, wrap_ldul_le); } =20 tcg_target_ulong helper_be_ldul_mmu(CPUArchState *env, target_ulong addr, @@ -1482,14 +1477,14 @@ uint64_t helper_le_ldq_mmu(CPUArchState *env, targe= t_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEQ, false, - helper_le_ldq_mmu, ldq_le_p); + helper_le_ldq_mmu, ldq_le_p, ldq_be_p); } =20 uint64_t helper_be_ldq_mmu(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEQ, false, - helper_be_ldq_mmu, ldq_be_p); + helper_be_ldq_mmu, ldq_be_p, ldq_le_p); } =20 /* @@ -1563,7 +1558,7 @@ static inline void wrap_stl_le(void *haddr, uint64_t = val) static inline void QEMU_ALWAYS_INLINE store_helper(CPUArchState *env, target_ulong addr, uint64_t val, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op, - StoreHelper *direct) + StoreHelper *direct, StoreHelper *direct_swap) { uintptr_t mmu_idx =3D get_mmuidx(oi); uintptr_t index =3D tlb_index(env, mmu_idx, addr); @@ -1608,16 +1603,22 @@ store_helper(CPUArchState *env, target_ulong addr, = uint64_t val, /* On watchpoint hit, this will longjmp out. */ cpu_check_watchpoint(env_cpu(env), addr, size, iotlbentry->attrs, BP_MEM_WRITE, retaddr); - - /* The backing page may or may not require I/O. */ - tlb_addr &=3D ~TLB_WATCHPOINT; - if ((tlb_addr & ~TARGET_PAGE_MASK) =3D=3D 0) { - goto do_aligned_access; - } } =20 /* Handle I/O access. */ - io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, op); + if (likely(tlb_addr & (TLB_MMIO | TLB_NOTDIRTY))) { + io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, + op ^ (tlb_addr & TLB_BSWAP ? MO_BSWAP : 0)); + return; + } + + haddr =3D (void *)((uintptr_t)addr + entry->addend); + + if (unlikely(tlb_addr & TLB_BSWAP)) { + direct_swap(haddr, val); + } else { + direct(haddr, val); + } return; } =20 @@ -1686,7 +1687,6 @@ store_helper(CPUArchState *env, target_ulong addr, ui= nt64_t val, return; } =20 - do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); direct(haddr, val); } @@ -1694,43 +1694,47 @@ store_helper(CPUArchState *env, target_ulong addr, = uint64_t val, void helper_ret_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_UB, wrap_stb); + store_helper(env, addr, val, oi, retaddr, MO_UB, wrap_stb, wrap_stb); } =20 void helper_le_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_LEUW, wrap_stw_le); + store_helper(env, addr, val, oi, retaddr, MO_LEUW, + wrap_stw_le, wrap_stw_be); } =20 void helper_be_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_BEUW, wrap_stw_be); + store_helper(env, addr, val, oi, retaddr, MO_BEUW, + wrap_stw_be, wrap_stw_le); } =20 void helper_le_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_LEUL, wrap_stl_le); + store_helper(env, addr, val, oi, retaddr, MO_LEUL, + wrap_stl_le, wrap_stl_be); } =20 void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_BEUL, wrap_stl_be); + store_helper(env, addr, val, oi, retaddr, MO_BEUL, + wrap_stl_be, wrap_stl_le); } =20 void helper_le_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_LEQ, stq_le_p); + store_helper(env, addr, val, oi, retaddr, MO_LEQ, stq_le_p, stq_be_p); } =20 void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, TCGMemOpIdx oi, uintptr_t retaddr) { - store_helper(env, addr, val, oi, retaddr, MO_BEQ, stq_be_p); + store_helper(env, addr, val, oi, retaddr, MO_BEQ, stq_be_p, stq_le_p); } =20 /* First set of helpers allows passing in of OI and RETADDR. This makes @@ -1796,7 +1800,7 @@ static uint64_t full_ldub_cmmu(CPUArchState *env, tar= get_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_8, true, - full_ldub_cmmu, wrap_ldub); + full_ldub_cmmu, wrap_ldub, wrap_ldub); } =20 uint8_t helper_ret_ldb_cmmu(CPUArchState *env, target_ulong addr, @@ -1809,7 +1813,7 @@ static uint64_t full_le_lduw_cmmu(CPUArchState *env, = target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEUW, true, - full_le_lduw_cmmu, wrap_lduw_le); + full_le_lduw_cmmu, wrap_lduw_le, wrap_lduw_be); } =20 uint16_t helper_le_ldw_cmmu(CPUArchState *env, target_ulong addr, @@ -1822,7 +1826,7 @@ static uint64_t full_be_lduw_cmmu(CPUArchState *env, = target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEUW, true, - full_be_lduw_cmmu, wrap_lduw_be); + full_be_lduw_cmmu, wrap_lduw_be, wrap_lduw_le); } =20 uint16_t helper_be_ldw_cmmu(CPUArchState *env, target_ulong addr, @@ -1835,7 +1839,7 @@ static uint64_t full_le_ldul_cmmu(CPUArchState *env, = target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEUL, true, - full_le_ldul_cmmu, wrap_ldul_le); + full_le_ldul_cmmu, wrap_ldul_le, wrap_ldul_be); } =20 uint32_t helper_le_ldl_cmmu(CPUArchState *env, target_ulong addr, @@ -1848,7 +1852,7 @@ static uint64_t full_be_ldul_cmmu(CPUArchState *env, = target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEUL, true, - full_be_ldul_cmmu, wrap_ldul_be); + full_be_ldul_cmmu, wrap_ldul_be, wrap_ldul_le); } =20 uint32_t helper_be_ldl_cmmu(CPUArchState *env, target_ulong addr, @@ -1861,12 +1865,12 @@ uint64_t helper_le_ldq_cmmu(CPUArchState *env, targ= et_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_LEQ, true, - helper_le_ldq_cmmu, ldq_le_p); + helper_le_ldq_cmmu, ldq_le_p, ldq_be_p); } =20 uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr) { return load_helper(env, addr, oi, retaddr, MO_BEQ, true, - helper_be_ldq_cmmu, ldq_be_p); + helper_be_ldq_cmmu, ldq_be_p, ldq_le_p); } --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125260; cv=none; d=zoho.com; s=zohoarc; b=JQ9m7TViqwyGMgPzYLSM8Oe9oyFuaNdRqBaNgCa/jLczSqge/dKfV9KM1d0ZtD0/2c/3h/D76mp+b7R/54WKusHqOKEAzt4ht3tEOL+3HbNxnsPrbQPUffdQX4stF+o6/DDW5JczBv03P/QCjtiHUmo7qV4eoINSHHWBuBRDYRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125260; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=dpN/rK4KxftzjyqayID53P95kBVBbhlVooKl6DB2vE0=; b=dGMNfyk1cICJiCNHWUyP4Kh1WNeek0sn/Nd60EIDznx5MnAp7wU2E3mtwX2C1poE2T5jt27Z/S++cG6tkOFcpaad+qy/kou+K3zKZFWSI/jXHLCRzQ4Qtc1UnKuNoxbEQ9iYyb2bVnXWfHwdeJX0c2qaM6QNeu2/P2oOwZ1VU48= 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 1569125260414174.7583223913349; Sat, 21 Sep 2019 21:07:40 -0700 (PDT) Received: from localhost ([::1]:45026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt9u-0004UI-AQ for importer@patchew.org; Sun, 22 Sep 2019 00:07:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40891) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxx-0001gd-VL for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxw-0008GQ-6C for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:17 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:36457) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxv-0008G4-V3 for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:16 -0400 Received: by mail-pg1-x544.google.com with SMTP id h17so3457796pgb.3 for ; Sat, 21 Sep 2019 20:55:15 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:14 -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=dpN/rK4KxftzjyqayID53P95kBVBbhlVooKl6DB2vE0=; b=X9smUx9k0xG6l1/ESGihAGGwsL7wG9kHAlKQerk6LIqJOJhr3/sRgvl/wwoiEKBSHu ACdzgQk+TqHAn0pgQohUJUJ0vkpQZaK/O9/OuO/JX8yQYdlWyllpsd9viGAUjsNpJ7zf JVOZur0sbBgKBVqpVVg5xO1BymhBS96DNg34RgczJ/PtY/uGjOH7M6nCvanKOmzZEPZg vjG9gsUapw7Ph10KlWeJRwDBM6TeUsGXH7NoAeOv14fIrF1RmT8HQly+gf0hPhB9Jnzl mxBMmZAvCGVSdbyrqlPxMS1Lj+AjuVgGTsqYSmQoDLEItx/5LEnMxZuyTMXpFraJ3FSk /Dkw== 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=dpN/rK4KxftzjyqayID53P95kBVBbhlVooKl6DB2vE0=; b=cfRuDUF755ndVwHSgFCxtA9cyx0e2xv4pX1NtoBq7vU2S3gH48716BbBUSZuWVC+vJ fp6sRhEIDb0c91TFfOFAFZdLBnSe80aGnDqXQZziDA2tLiLcPgru/zxyNehVf/AZD+qu UfQxQpASl++2LTP+/UA7mrThmMZ+zcBpXXyrGicXoWckqKC11CjO0cBlVhnbKjK0sSId Neik4y+apsrH3NMoWLsujWZpFkfO6We0F4J+BiIDsXEFd9oSLkhwgCVIMPuC99ULilI8 GkSgIUg9VmOux3swB1F0+eS7VeCGEPTb4K2xnJKvEZvOXvoVwpmUijL4eqrQEZc6hXHN RE3A== X-Gm-Message-State: APjAAAXucC/CnwMAK+qinKVsKKEcIjWVgYF2zbmXFLaxSCVS00hLACYH ZVPVbPh4ACGivfNZLESDO0j9I1DkUzU= X-Google-Smtp-Source: APXvYqxm6KLawvZ0wTuK7gtyK7AkNmT2PfnUGKG2UxINQ6KBd9ngjUNGnML3aH3cE7XyHpbqs3mcbQ== X-Received: by 2002:a62:7597:: with SMTP id q145mr25728808pfc.181.1569124514706; Sat, 21 Sep 2019 20:55:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/20] exec: Adjust notdirty tracing Date: Sat, 21 Sep 2019 20:54:49 -0700 Message-Id: <20190922035458.14879-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::544 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The memory_region_tb_read tracepoint is unreachable, since notdirty is supposed to apply only to writes. The memory_region_tb_write tracepoint is mis-named, because notdirty is not only used for TB invalidation. It is also used for e.g. VGA RAM updates and migration. Replace memory_region_tb_write with memory_notdirty_write_access, and place it in memory_notdirty_write_prepare where it can catch all of the instances. Add memory_notdirty_set_dirty to log when we no longer intercept writes to a page. Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- exec.c | 3 +++ memory.c | 4 ---- trace-events | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index 33bd0e36c1..7ce0515635 100644 --- a/exec.c +++ b/exec.c @@ -2721,6 +2721,8 @@ void memory_notdirty_write_prepare(NotDirtyInfo *ndi, ndi->size =3D size; ndi->pages =3D NULL; =20 + trace_memory_notdirty_write_access(mem_vaddr, ram_addr, size); + assert(tcg_enabled()); if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { ndi->pages =3D page_collection_lock(ram_addr, ram_addr + size); @@ -2745,6 +2747,7 @@ void memory_notdirty_write_complete(NotDirtyInfo *ndi) /* we remove the notdirty callback only if the code has been flushed */ if (!cpu_physical_memory_is_clean(ndi->ram_addr)) { + trace_memory_notdirty_set_dirty(ndi->mem_vaddr); tlb_set_dirty(ndi->cpu, ndi->mem_vaddr); } } diff --git a/memory.c b/memory.c index b9dd6b94ca..57c44c97db 100644 --- a/memory.c +++ b/memory.c @@ -438,7 +438,6 @@ static MemTxResult memory_region_read_accessor(MemoryR= egion *mr, /* Accesses to code which has previously been translated into a TB= show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ - trace_memory_region_tb_read(get_cpu_index(), addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); @@ -465,7 +464,6 @@ static MemTxResult memory_region_read_with_attrs_access= or(MemoryRegion *mr, /* Accesses to code which has previously been translated into a TB= show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ - trace_memory_region_tb_read(get_cpu_index(), addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); @@ -490,7 +488,6 @@ static MemTxResult memory_region_write_accessor(MemoryR= egion *mr, /* Accesses to code which has previously been translated into a TB= show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ - trace_memory_region_tb_write(get_cpu_index(), addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); @@ -515,7 +512,6 @@ static MemTxResult memory_region_write_with_attrs_acces= sor(MemoryRegion *mr, /* Accesses to code which has previously been translated into a TB= show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ - trace_memory_region_tb_write(get_cpu_index(), addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); diff --git a/trace-events b/trace-events index 823a4ae64e..20821ba545 100644 --- a/trace-events +++ b/trace-events @@ -52,14 +52,14 @@ dma_map_wait(void *dbs) "dbs=3D%p" find_ram_offset(uint64_t size, uint64_t offset) "size: 0x%" PRIx64 " @ 0x%= " PRIx64 find_ram_offset_loop(uint64_t size, uint64_t candidate, uint64_t offset, u= int64_t next, uint64_t mingap) "trying size: 0x%" PRIx64 " @ 0x%" PRIx64 ",= offset: 0x%" PRIx64" next: 0x%" PRIx64 " mingap: 0x%" PRIx64 ram_block_discard_range(const char *rbname, void *hva, size_t length, bool= need_madvise, bool need_fallocate, int ret) "%s@%p + 0x%zx: madvise: %d fa= llocate: %d ret: %d" +memory_notdirty_write_access(uint64_t vaddr, uint64_t ram_addr, unsigned s= ize) "0x%" PRIx64 " ram_addr 0x%" PRIx64 " size %u" +memory_notdirty_set_dirty(uint64_t vaddr) "0x%" PRIx64 =20 # memory.c memory_region_ops_read(int cpu_index, void *mr, uint64_t addr, uint64_t va= lue, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %= u" memory_region_ops_write(int cpu_index, void *mr, uint64_t addr, uint64_t v= alue, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size = %u" memory_region_subpage_read(int cpu_index, void *mr, uint64_t offset, uint6= 4_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx64= " size %u" memory_region_subpage_write(int cpu_index, void *mr, uint64_t offset, uint= 64_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx6= 4" size %u" -memory_region_tb_read(int cpu_index, uint64_t addr, uint64_t value, unsign= ed size) "cpu %d addr 0x%"PRIx64" value 0x%"PRIx64" size %u" -memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsig= ned size) "cpu %d addr 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_ram_device_read(int cpu_index, void *mr, uint64_t addr, uint= 64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64"= size %u" memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uin= t64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64= " size %u" flatview_new(void *view, void *root) "%p (root %p)" --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125255; cv=none; d=zoho.com; s=zohoarc; b=TF0kZTeDqYLNlPADyqX/Om5yYWzP5+jmCjHCZc/6E5CV44x7/6LDnFU14y6cVqTDHFtRPAEnTrkC/1OQjMD3vK7xU3J0fkDa0SSnBvTD1cNnylHbodS6PBxCRo/Tzk7qxJiE9uGi9IcGFQ5Crz7okjPO2T6yX+54m2PzjO/B57s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125255; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+uIocOn9VX/i7GnqHaWrqX+b4SaiUHijmC0FIzPROHE=; b=dEn3LA6mKf3Z3r3XGwy6IuJLII/F8SUtTdU1MHrOJIPMaSPVLS5Cc0RA68m/FWAz4/Fae9cgzjYiOW7yTwSDs34zfgEjHO5oMrib95fYg2NwQDPWVAIr05fS1tQ18wDhh0fYCEg9la+G80RUAZJZvLr9iDceiZS23PRbVYIJCAo= 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 1569125255082823.9468265703208; Sat, 21 Sep 2019 21:07:35 -0700 (PDT) Received: from localhost ([::1]:45022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBt9n-0004GW-Ln for importer@patchew.org; Sun, 22 Sep 2019 00:07:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40908) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsxz-0001jx-U1 for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxx-0008H6-GE for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:19 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:33390) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxx-0008Gn-6T for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:17 -0400 Received: by mail-pg1-x543.google.com with SMTP id i30so266403pgl.0 for ; Sat, 21 Sep 2019 20:55:17 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:15 -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=+uIocOn9VX/i7GnqHaWrqX+b4SaiUHijmC0FIzPROHE=; b=XLB7paZW8USoqtq1oG48bOcStD6Xn1S+IBwEQBm/3Bizq3L2PyopVXKxwM83lauig9 sE53dKobdVWE/PzTTzYOe9G1Yd72SzozRNavwyBYucz6aR8AlHOArXVRg7oSMjqb3hYa kS0QIwCHlAsiFpjp/YoJO9dyDbmOTZQcDOj/z3y+7y5/VhX/5x+q7n7s0dkxp+rIZD0X pk1b/quzQfnsgRVJKDHU5JnOE/rRxYneK7bOcH9uYZd6IaR1uqu2+Vl5JmvFkCdInF0e 8eVQo9Ot0S6z6BEvcBDt+vjr29PY5piA3sAamDFNeaYyet+wjevGU73oZvSsjb7ZkvOh 5Rxg== 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=+uIocOn9VX/i7GnqHaWrqX+b4SaiUHijmC0FIzPROHE=; b=pLgBmSrZR3HiyyVotfJfvHBvWK10mz6OD/nK5MC0bbiaTSouOBAGkyoH2qxl6YMj+o ib3/Ub8/wYfNH2K8Z2PGCWJTgzyP7bcFOwe91jLCivHcdZb8x3vSzoJn8sRe8jGIVd2r SfqdDpthkUlKufOqLLp3CfKoljyMepFKllZ5Hs8Ed9TyN/yqm0ooWllHCQUvh1zGdQ6q U4Q1nGniQfC6Ww9qw7GlojPuy3cI3j8rVQ1zDJG9ul6oVTTRi0ArEzRhSZ8Php2qRjU6 9sB0S30X1b9Yj9NgUxK9cbqxJDiq46jWYTwF5JjVbcrl4fUE6fCN4JuRTOqBbJ2MzPMS 5dig== X-Gm-Message-State: APjAAAXISB/Fi835aBYx8mkZFSORQrewLZ3661RNvAYc6gJ7Vb8tawX6 RBsgnBCAuzSe24elmONtfJVb2MAJJvQ= X-Google-Smtp-Source: APXvYqz05/gQGw7gkik7VN++tyucfLshev+aZ8O5g2aakphzfVDBoPHhhbaA4DXeCXqEPJcGdV6LAg== X-Received: by 2002:a17:90a:8d84:: with SMTP id d4mr13473928pjo.139.1569124515935; Sat, 21 Sep 2019 20:55:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/20] cputlb: Move ROM handling from I/O path to TLB path Date: Sat, 21 Sep 2019 20:54:50 -0700 Message-Id: <20190922035458.14879-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::543 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It does not require going through the whole I/O path in order to discard a write. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- include/exec/cpu-all.h | 5 ++++- include/exec/cpu-common.h | 1 - accel/tcg/cputlb.c | 35 +++++++++++++++++++-------------- exec.c | 41 +-------------------------------------- 4 files changed, 25 insertions(+), 57 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 1ebd1b59ab..9f0b17802e 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -348,12 +348,15 @@ CPUArchState *cpu_copy(CPUArchState *env); #define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4)) /* Set if TLB entry requires byte swap. */ #define TLB_BSWAP (1 << (TARGET_PAGE_BITS_MIN - 5)) +/* Set if TLB entry writes ignored. */ +#define TLB_ROM (1 << (TARGET_PAGE_BITS_MIN - 6)) =20 /* Use this mask to check interception with an alignment mask * in a TCG backend. */ #define TLB_FLAGS_MASK \ - (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT | TLB_BSW= AP) + (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO \ + | TLB_WATCHPOINT | TLB_BSWAP | TLB_ROM) =20 /** * tlb_hit_page: return true if page aligned @addr is a hit against the diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index f7dbe75fbc..1c0e03ddc2 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -100,7 +100,6 @@ void qemu_flush_coalesced_mmio_buffer(void); =20 void cpu_flush_icache_range(hwaddr start, hwaddr len); =20 -extern struct MemoryRegion io_mem_rom; extern struct MemoryRegion io_mem_notdirty; =20 typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index cb603917a2..7ab523d7ec 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -577,7 +577,7 @@ static void tlb_reset_dirty_range_locked(CPUTLBEntry *t= lb_entry, { uintptr_t addr =3D tlb_entry->addr_write; =20 - if ((addr & (TLB_INVALID_MASK | TLB_MMIO | TLB_NOTDIRTY)) =3D=3D 0) { + if ((addr & (TLB_INVALID_MASK | TLB_MMIO | TLB_ROM | TLB_NOTDIRTY)) = =3D=3D 0) { addr &=3D TARGET_PAGE_MASK; addr +=3D tlb_entry->addend; if ((addr - start) < length) { @@ -745,7 +745,6 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulon= g vaddr, address |=3D TLB_MMIO; addend =3D 0; } else { - /* TLB_MMIO for rom/romd handled below */ addend =3D (uintptr_t)memory_region_get_ram_ptr(section->mr) + xla= t; } =20 @@ -822,16 +821,17 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ul= ong vaddr, =20 tn.addr_write =3D -1; if (prot & PAGE_WRITE) { - if ((memory_region_is_ram(section->mr) && section->readonly) - || memory_region_is_romd(section->mr)) { - /* Write access calls the I/O callback. */ - tn.addr_write =3D address | TLB_MMIO; - } else if (memory_region_is_ram(section->mr) - && cpu_physical_memory_is_clean( - memory_region_get_ram_addr(section->mr) + xlat)) { - tn.addr_write =3D address | TLB_NOTDIRTY; - } else { - tn.addr_write =3D address; + tn.addr_write =3D address; + if (memory_region_is_romd(section->mr)) { + /* Use the MMIO path so that the device can switch states. */ + tn.addr_write |=3D TLB_MMIO; + } else if (memory_region_is_ram(section->mr)) { + if (section->readonly) { + tn.addr_write |=3D TLB_ROM; + } else if (cpu_physical_memory_is_clean( + memory_region_get_ram_addr(section->mr) + xlat)) { + tn.addr_write |=3D TLB_NOTDIRTY; + } } if (prot & PAGE_WRITE_INV) { tn.addr_write |=3D TLB_INVALID_MASK; @@ -904,7 +904,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; cpu->mem_io_pc =3D retaddr; - if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !cpu->can_do_io= ) { + if (mr !=3D &io_mem_notdirty && !cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } =20 @@ -945,7 +945,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry = *iotlbentry, section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; - if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !cpu->can_do_io= ) { + if (mr !=3D &io_mem_notdirty && !cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } cpu->mem_io_vaddr =3D addr; @@ -1125,7 +1125,7 @@ void *probe_access(CPUArchState *env, target_ulong ad= dr, int size, } =20 /* Reject I/O access, or other required slow-path. */ - if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO | TLB_BSWAP)) { + if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO | TLB_BSWAP | TLB_ROM)) { return NULL; } =20 @@ -1612,6 +1612,11 @@ store_helper(CPUArchState *env, target_ulong addr, u= int64_t val, return; } =20 + /* Ignore writes to ROM. */ + if (unlikely(tlb_addr & TLB_ROM)) { + return; + } + haddr =3D (void *)((uintptr_t)addr + entry->addend); =20 if (unlikely(tlb_addr & TLB_BSWAP)) { diff --git a/exec.c b/exec.c index 7ce0515635..e21e068535 100644 --- a/exec.c +++ b/exec.c @@ -88,7 +88,7 @@ static MemoryRegion *system_io; AddressSpace address_space_io; AddressSpace address_space_memory; =20 -MemoryRegion io_mem_rom, io_mem_notdirty; +MemoryRegion io_mem_notdirty; static MemoryRegion io_mem_unassigned; #endif =20 @@ -158,7 +158,6 @@ typedef struct subpage_t { =20 #define PHYS_SECTION_UNASSIGNED 0 #define PHYS_SECTION_NOTDIRTY 1 -#define PHYS_SECTION_ROM 2 =20 static void io_mem_init(void); static void memory_map_init(void); @@ -1441,8 +1440,6 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; if (!section->readonly) { iotlb |=3D PHYS_SECTION_NOTDIRTY; - } else { - iotlb |=3D PHYS_SECTION_ROM; } } else { AddressSpaceDispatch *d; @@ -2968,38 +2965,6 @@ static uint16_t dummy_section(PhysPageMap *map, Flat= View *fv, MemoryRegion *mr) return phys_section_add(map, §ion); } =20 -static void readonly_mem_write(void *opaque, hwaddr addr, - uint64_t val, unsigned size) -{ - /* Ignore any write to ROM. */ -} - -static bool readonly_mem_accepts(void *opaque, hwaddr addr, - unsigned size, bool is_write, - MemTxAttrs attrs) -{ - return is_write; -} - -/* This will only be used for writes, because reads are special cased - * to directly access the underlying host ram. - */ -static const MemoryRegionOps readonly_mem_ops =3D { - .write =3D readonly_mem_write, - .valid.accepts =3D readonly_mem_accepts, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - .unaligned =3D false, - }, - .impl =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - .unaligned =3D false, - }, -}; - MemoryRegionSection *iotlb_to_section(CPUState *cpu, hwaddr index, MemTxAttrs attrs) { @@ -3013,8 +2978,6 @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu, =20 static void io_mem_init(void) { - memory_region_init_io(&io_mem_rom, NULL, &readonly_mem_ops, - NULL, NULL, UINT64_MAX); memory_region_init_io(&io_mem_unassigned, NULL, &unassigned_mem_ops, N= ULL, NULL, UINT64_MAX); =20 @@ -3035,8 +2998,6 @@ AddressSpaceDispatch *address_space_dispatch_new(Flat= View *fv) assert(n =3D=3D PHYS_SECTION_UNASSIGNED); n =3D dummy_section(&d->map, fv, &io_mem_notdirty); assert(n =3D=3D PHYS_SECTION_NOTDIRTY); - n =3D dummy_section(&d->map, fv, &io_mem_rom); - assert(n =3D=3D PHYS_SECTION_ROM); =20 d->phys_map =3D (PhysPageEntry) { .ptr =3D PHYS_MAP_NODE_NIL, .skip = =3D 1 }; =20 --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125431; cv=none; d=zoho.com; s=zohoarc; b=nf2/vFLtdoJ/x6VwUNMNruNtS1lrmoL53MhOFRfIKiF1sClha9Zzrqr9UXrjXkw0bHa/IqtlCi1tBhXqGBJQBgOs/AM12+CiBF7NmEt3/4kSNlPylFD1GUW4MxrXq0i54cXf3FI+CR5HL9qfhxKY0Oc8FjYQnep+kDQS1d9J/D4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125431; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=l0x6N8LdqjYYjz2q3/Zm+HQDZY+orZYy+CSbM46axJQ=; b=iyi55yOpWq+7ruB3Y+59lIWllJOKv8v/UrZE4jzXwIrPc0/EzFPjp6ZyydrJJEKJbO4wSuSaKb02PGPRd+P8Qu4Bppk2B8mDSvNHgUKP7v9IaZUVDiAigjTrjDeWVKJWnbVoQ01Jh+30SpfBqdtYDSpLfh5HnOZSScgmIcNjKoE= 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 1569125431132134.9727806402326; Sat, 21 Sep 2019 21:10:31 -0700 (PDT) Received: from localhost ([::1]:45066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtCf-0007pX-S5 for importer@patchew.org; Sun, 22 Sep 2019 00:10:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40920) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy1-0001mB-5U for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsxz-0008I3-3m for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:21 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:44909) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxy-0008Hc-OS for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:18 -0400 Received: by mail-pg1-x541.google.com with SMTP id g3so4419794pgs.11 for ; Sat, 21 Sep 2019 20:55:18 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:16 -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=l0x6N8LdqjYYjz2q3/Zm+HQDZY+orZYy+CSbM46axJQ=; b=F5aLi2qV/M0uhpdodo2zWB7S/Y/bvtX1+R7UFYy4ggy+AaDXhvGqeqDMr/VJouP0sw 68eFCDwet4OxQ+zr/FOM9s+YW7AYXZUu5D3hD5BRThcyCF5ESO/kQ0HHRohz/G2YVM0o YboXCHH4Q1kknSyO42zOVdeaYEfJDwrBYxY62ggcwSSm4GjiT4PVnBNcxIabWQdMkXme 9ITrk2x1qvEFVWGDIu43JQpsVxmu1P8alqSXUvbihJl4433GKXmj0tWlC5SoE485kWAs 6RisMav8gzsXuwwG3eBeD6HN3ij6vShsVG0e4k1WR0YczK4Z0ZnuCTq1o2Gh2hAgMUEC Hbfg== 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=l0x6N8LdqjYYjz2q3/Zm+HQDZY+orZYy+CSbM46axJQ=; b=ac2jMMdJ/GxL94oyQdzU3si+fKoZ+komVNDzShxod/YrTvAXWtyuK6HxwPhhbrayCt NC51WSQ3ZNEe1uHhYQnX4QZXG05Tw3D59pK7ftBs6iKaMuDLuyo2Yoji//N6d9QB2HNh Bwft2vsIvX60cp25TZ9nQsFlI1uccAkv6GhOSMla0YIgE2+dsydIjCVp3/6se8ObrJuc RuYEGdo2eTkR1qAWq5yDv7Tll2kHJ8SgPCPoqlIW5CzvDKYdlecNnZnxGwRAk4Zpbd7K EASX0zOqZguvZHQhfpQPxmsnwZbDKhM1QQCEahwB/iqkqE/i5kLBGGXOCwkk4H2ckkMU H/vw== X-Gm-Message-State: APjAAAWAZOtCukD1sHqKqmAi/Kn6TiB3AFJQ6jgYCKxlRD8ocJVbuH4f v39+QSi1FqVui6FkQDgw3PfeugtRvmI= X-Google-Smtp-Source: APXvYqxJvoNyBxZlVzD1XetV19iz21uk1Nfkwyei7YxXXQEm9qUaMj9Yuwk5cJZ7D37X/3ksONeTjA== X-Received: by 2002:a63:d60:: with SMTP id 32mr23212838pgn.316.1569124517127; Sat, 21 Sep 2019 20:55:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/20] cputlb: Move NOTDIRTY handling from I/O path to TLB path Date: Sat, 21 Sep 2019 20:54:51 -0700 Message-Id: <20190922035458.14879-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::541 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pages that we want to track for NOTDIRTY are RAM. We do not really need to go through the I/O path to handle them. Signed-off-by: Richard Henderson Acked-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/cpu-common.h | 2 -- accel/tcg/cputlb.c | 26 +++++++++++++++++--- exec.c | 50 --------------------------------------- memory.c | 16 ------------- 4 files changed, 23 insertions(+), 71 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 1c0e03ddc2..81753bbb34 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -100,8 +100,6 @@ void qemu_flush_coalesced_mmio_buffer(void); =20 void cpu_flush_icache_range(hwaddr start, hwaddr len); =20 -extern struct MemoryRegion io_mem_notdirty; - typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque); =20 int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 7ab523d7ec..b7bd738115 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -904,7 +904,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; cpu->mem_io_pc =3D retaddr; - if (mr !=3D &io_mem_notdirty && !cpu->can_do_io) { + if (!cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } =20 @@ -945,7 +945,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry = *iotlbentry, section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; - if (mr !=3D &io_mem_notdirty && !cpu->can_do_io) { + if (!cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } cpu->mem_io_vaddr =3D addr; @@ -1606,7 +1606,7 @@ store_helper(CPUArchState *env, target_ulong addr, ui= nt64_t val, } =20 /* Handle I/O access. */ - if (likely(tlb_addr & (TLB_MMIO | TLB_NOTDIRTY))) { + if (tlb_addr & TLB_MMIO) { io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, op ^ (tlb_addr & TLB_BSWAP ? MO_BSWAP : 0)); return; @@ -1619,6 +1619,26 @@ store_helper(CPUArchState *env, target_ulong addr, u= int64_t val, =20 haddr =3D (void *)((uintptr_t)addr + entry->addend); =20 + /* Handle clean RAM pages. */ + if (tlb_addr & TLB_NOTDIRTY) { + NotDirtyInfo ndi; + + /* We require mem_io_pc in tb_invalidate_phys_page_range. */ + env_cpu(env)->mem_io_pc =3D retaddr; + + memory_notdirty_write_prepare(&ndi, env_cpu(env), addr, + addr + iotlbentry->addr, size); + + if (unlikely(tlb_addr & TLB_BSWAP)) { + direct_swap(haddr, val); + } else { + direct(haddr, val); + } + + memory_notdirty_write_complete(&ndi); + return; + } + if (unlikely(tlb_addr & TLB_BSWAP)) { direct_swap(haddr, val); } else { diff --git a/exec.c b/exec.c index e21e068535..abf58b68a0 100644 --- a/exec.c +++ b/exec.c @@ -88,7 +88,6 @@ static MemoryRegion *system_io; AddressSpace address_space_io; AddressSpace address_space_memory; =20 -MemoryRegion io_mem_notdirty; static MemoryRegion io_mem_unassigned; #endif =20 @@ -157,7 +156,6 @@ typedef struct subpage_t { } subpage_t; =20 #define PHYS_SECTION_UNASSIGNED 0 -#define PHYS_SECTION_NOTDIRTY 1 =20 static void io_mem_init(void); static void memory_map_init(void); @@ -1438,9 +1436,6 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, if (memory_region_is_ram(section->mr)) { /* Normal RAM. */ iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; - if (!section->readonly) { - iotlb |=3D PHYS_SECTION_NOTDIRTY; - } } else { AddressSpaceDispatch *d; =20 @@ -2749,42 +2744,6 @@ void memory_notdirty_write_complete(NotDirtyInfo *nd= i) } } =20 -/* Called within RCU critical section. */ -static void notdirty_mem_write(void *opaque, hwaddr ram_addr, - uint64_t val, unsigned size) -{ - NotDirtyInfo ndi; - - memory_notdirty_write_prepare(&ndi, current_cpu, current_cpu->mem_io_v= addr, - ram_addr, size); - - stn_p(qemu_map_ram_ptr(NULL, ram_addr), size, val); - memory_notdirty_write_complete(&ndi); -} - -static bool notdirty_mem_accepts(void *opaque, hwaddr addr, - unsigned size, bool is_write, - MemTxAttrs attrs) -{ - return is_write; -} - -static const MemoryRegionOps notdirty_mem_ops =3D { - .write =3D notdirty_mem_write, - .valid.accepts =3D notdirty_mem_accepts, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - .unaligned =3D false, - }, - .impl =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - .unaligned =3D false, - }, -}; - /* Generate a debug exception if a watchpoint has been hit. */ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, MemTxAttrs attrs, int flags, uintptr_t ra) @@ -2980,13 +2939,6 @@ static void io_mem_init(void) { memory_region_init_io(&io_mem_unassigned, NULL, &unassigned_mem_ops, N= ULL, NULL, UINT64_MAX); - - /* io_mem_notdirty calls tb_invalidate_phys_page_fast, - * which can be called without the iothread mutex. - */ - memory_region_init_io(&io_mem_notdirty, NULL, ¬dirty_mem_ops, NULL, - NULL, UINT64_MAX); - memory_region_clear_global_locking(&io_mem_notdirty); } =20 AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv) @@ -2996,8 +2948,6 @@ AddressSpaceDispatch *address_space_dispatch_new(Flat= View *fv) =20 n =3D dummy_section(&d->map, fv, &io_mem_unassigned); assert(n =3D=3D PHYS_SECTION_UNASSIGNED); - n =3D dummy_section(&d->map, fv, &io_mem_notdirty); - assert(n =3D=3D PHYS_SECTION_NOTDIRTY); =20 d->phys_map =3D (PhysPageEntry) { .ptr =3D PHYS_MAP_NODE_NIL, .skip = =3D 1 }; =20 diff --git a/memory.c b/memory.c index 57c44c97db..a99b8c0767 100644 --- a/memory.c +++ b/memory.c @@ -434,10 +434,6 @@ static MemTxResult memory_region_read_accessor(Memory= Region *mr, tmp =3D mr->ops->read(mr->opaque, addr, size); if (mr->subpage) { trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, s= ize); - } else if (mr =3D=3D &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB= show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); @@ -460,10 +456,6 @@ static MemTxResult memory_region_read_with_attrs_acces= sor(MemoryRegion *mr, r =3D mr->ops->read_with_attrs(mr->opaque, addr, &tmp, size, attrs); if (mr->subpage) { trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, s= ize); - } else if (mr =3D=3D &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB= show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); @@ -484,10 +476,6 @@ static MemTxResult memory_region_write_accessor(Memory= Region *mr, =20 if (mr->subpage) { trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, = size); - } else if (mr =3D=3D &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB= show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); @@ -508,10 +496,6 @@ static MemTxResult memory_region_write_with_attrs_acce= ssor(MemoryRegion *mr, =20 if (mr->subpage) { trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, = size); - } else if (mr =3D=3D &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB= show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125396; cv=none; d=zoho.com; s=zohoarc; b=GK/KHsHuRn+8njyWSevbm33vKysRYIipgQQ+2sGPhLNuKCEm8O3PZ1UnenwjdXjsmX2tWIHwz4b+kwEJhfzlMrBncuvRVVedBTwxD1x1NbME3m6NWaqcbIk7i7LnBQ0gdM7MsG4tX19vRvqLyeCur+Bef1lJt2s65GQ6w0tDCko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125396; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QxZNUVHClZ6kub1hmpcWcaD4e3TTiMLpQiUcrzE3llI=; b=FecNMXWLTyMeh0qVoL57YOboA7AmHVyWT7JDqjHNmZ3yF1rrU238Ff3o8ogWoktc5qfXVJUII00p49p3x2i7gvWHkd3iCbMEa/56uDF9EBpgPLLbuE3Z0w2vrfY29n2FgMCY3+DoRbcJMmkPYQfexixP/MmtGuaDIWDIA6xL0S4= 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 1569125396430122.21817324147128; Sat, 21 Sep 2019 21:09:56 -0700 (PDT) Received: from localhost ([::1]:45062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtC6-00079V-IC for importer@patchew.org; Sun, 22 Sep 2019 00:09:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40933) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy2-0001n8-8E for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsy0-0008Ia-5E for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:21 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:47022) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsxz-0008IB-Sb for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:20 -0400 Received: by mail-pg1-x543.google.com with SMTP id a3so5972642pgm.13 for ; Sat, 21 Sep 2019 20:55:19 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:17 -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=QxZNUVHClZ6kub1hmpcWcaD4e3TTiMLpQiUcrzE3llI=; b=mTCs34vvydaZZxX3xCghwuxVcQ7KkSJo3zxvKdjFDHF052AyPWlD0rMSkYpCwWV8u0 LJN9sv6EI3m1TTU86PZyY3FmL9HZZo8CyrXbM8Opwad42sE+8W5Qny/ehEglIMhvaRJU eaVJv2Exsn/y3sqrulBZhgsqyEumPS8IFW1qrxO3fQ76+5i3ooYYV6GVexA0paIwAe65 48N+yhh9ZVswEzMjRraVpjuwVWKBcZAGPv5dTiQGuKdoGEAiCPTC1RYp3yN1+nl7i9hl u1mlG/Fh6UKtx2hNq7OG/zTFaqL5eiqg27z1Ta6QQYnm7u3+JsNFKgpKUtygsYHEJtYS iJqA== 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=QxZNUVHClZ6kub1hmpcWcaD4e3TTiMLpQiUcrzE3llI=; b=mOdlkF6TLt3lIalr35b+OPUwjOrSUtC4zmkQolEvxqmANASb0XISjczRtDbx/UWw5F 5DGWmeoaTbOKixXuZ3lrr3FjBwFZ07DtzDTPQJ6qhY6rhb6mm9pmKTmfAIFUqvOA3s+T VgK7H/Bb8VtpAkh+BWPMvroPiwCLSc+sfijBwIJe/myMCaYoEu2oDYBUZbN8Ew69QZiE D46lXJ7309qhe9l/vYelxrw1XEtHKEHWSlj9xwaxvDt5yoAQojnogNytqBsACa3cn8NQ Eax6Kh3LEop3Iwi8gmqbOImBdM+RkXi9eFu+KVfjbEm4k0evVYL7uiMBjAPQ/HyiMEJj 01Bg== X-Gm-Message-State: APjAAAVapafrJmSC40yuRSsOOLZRYuXn6RadCuY4VjP8J/0tNzMbM9Wd WTkimvh186l1+OrtBIJaXmtix19mFYo= X-Google-Smtp-Source: APXvYqzzWQfhP4LHBlFvY9Dw5WRXGOeqA7/qqHtU3OwxRNnfvSCUsUbne9zJC0PriqoDg8sbTGXjMw== X-Received: by 2002:aa7:85d0:: with SMTP id z16mr26913148pfn.206.1569124518628; Sat, 21 Sep 2019 20:55:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/20] cputlb: Partially inline memory_region_section_get_iotlb Date: Sat, 21 Sep 2019 20:54:52 -0700 Message-Id: <20190922035458.14879-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::543 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is only one caller, tlb_set_page_with_attrs. We cannot inline the entire function because the AddressSpaceDispatch structure is private to exec.c, and cannot easily be moved to include/exec/memory-internal.h. Compute is_ram and is_romd once within tlb_set_page_with_attrs. Fold the number of tests against these predicates. Compute cpu_physical_memory_is_clean outside of the tlb lock region. Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 6 +--- accel/tcg/cputlb.c | 68 ++++++++++++++++++++++++++--------------- exec.c | 22 ++----------- 3 files changed, 47 insertions(+), 49 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 81b02eb2fe..49db07ba0b 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -509,11 +509,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int a= sidx, hwaddr addr, hwaddr *xlat, hwaddr *plen, MemTxAttrs attrs, int *prot); hwaddr memory_region_section_get_iotlb(CPUState *cpu, - MemoryRegionSection *section, - target_ulong vaddr, - hwaddr paddr, hwaddr xlat, - int prot, - target_ulong *address); + MemoryRegionSection *section); #endif =20 /* vl.c */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b7bd738115..1a839c0f82 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -704,13 +704,14 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ul= ong vaddr, MemoryRegionSection *section; unsigned int index; target_ulong address; - target_ulong code_address; + target_ulong write_address; uintptr_t addend; CPUTLBEntry *te, tn; hwaddr iotlb, xlat, sz, paddr_page; target_ulong vaddr_page; int asidx =3D cpu_asidx_from_attrs(cpu, attrs); int wp_flags; + bool is_ram, is_romd; =20 assert_cpu_is_self(cpu); =20 @@ -739,18 +740,46 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ul= ong vaddr, if (attrs.byte_swap) { address |=3D TLB_BSWAP; } - if (!memory_region_is_ram(section->mr) && - !memory_region_is_romd(section->mr)) { - /* IO memory case */ - address |=3D TLB_MMIO; - addend =3D 0; - } else { + + is_ram =3D memory_region_is_ram(section->mr); + is_romd =3D memory_region_is_romd(section->mr); + + if (is_ram || is_romd) { + /* RAM and ROMD both have associated host memory. */ addend =3D (uintptr_t)memory_region_get_ram_ptr(section->mr) + xla= t; + } else { + /* I/O does not; force the host address to NULL. */ + addend =3D 0; + } + + write_address =3D address; + if (is_ram) { + iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; + /* + * Computing is_clean is expensive; avoid all that unless + * the page is actually writable. + */ + if (prot & PAGE_WRITE) { + if (section->readonly) { + write_address |=3D TLB_ROM; + } else if (cpu_physical_memory_is_clean(iotlb)) { + write_address |=3D TLB_NOTDIRTY; + } + } + } else { + /* I/O or ROMD */ + iotlb =3D memory_region_section_get_iotlb(cpu, section) + xlat; + /* + * Writes to romd devices must go through MMIO to enable write. + * Reads to romd devices go through the ram_ptr found above, + * but of course reads to I/O must go through MMIO. + */ + write_address |=3D TLB_MMIO; + if (!is_romd) { + address =3D write_address; + } } =20 - code_address =3D address; - iotlb =3D memory_region_section_get_iotlb(cpu, section, vaddr_page, - paddr_page, xlat, prot, &addre= ss); wp_flags =3D cpu_watchpoint_address_matches(cpu, vaddr_page, TARGET_PAGE_SIZE); =20 @@ -790,8 +819,8 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulon= g vaddr, /* * At this point iotlb contains a physical section number in the lower * TARGET_PAGE_BITS, and either - * + the ram_addr_t of the page base of the target RAM (if NOTDIRTY o= r ROM) - * + the offset within section->mr of the page base (otherwise) + * + the ram_addr_t of the page base of the target RAM (RAM) + * + the offset within section->mr of the page base (I/O, ROMD) * We subtract the vaddr_page (which is page aligned and thus won't * disturb the low bits) to give an offset which can be added to the * (non-page-aligned) vaddr of the eventual memory access to get @@ -814,25 +843,14 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ul= ong vaddr, } =20 if (prot & PAGE_EXEC) { - tn.addr_code =3D code_address; + tn.addr_code =3D address; } else { tn.addr_code =3D -1; } =20 tn.addr_write =3D -1; if (prot & PAGE_WRITE) { - tn.addr_write =3D address; - if (memory_region_is_romd(section->mr)) { - /* Use the MMIO path so that the device can switch states. */ - tn.addr_write |=3D TLB_MMIO; - } else if (memory_region_is_ram(section->mr)) { - if (section->readonly) { - tn.addr_write |=3D TLB_ROM; - } else if (cpu_physical_memory_is_clean( - memory_region_get_ram_addr(section->mr) + xlat)) { - tn.addr_write |=3D TLB_NOTDIRTY; - } - } + tn.addr_write =3D write_address; if (prot & PAGE_WRITE_INV) { tn.addr_write |=3D TLB_INVALID_MASK; } diff --git a/exec.c b/exec.c index abf58b68a0..9c9cc811b3 100644 --- a/exec.c +++ b/exec.c @@ -1425,26 +1425,10 @@ bool cpu_physical_memory_snapshot_get_dirty(DirtyBi= tmapSnapshot *snap, =20 /* Called from RCU critical section */ hwaddr memory_region_section_get_iotlb(CPUState *cpu, - MemoryRegionSection *section, - target_ulong vaddr, - hwaddr paddr, hwaddr xlat, - int prot, - target_ulong *address) + MemoryRegionSection *section) { - hwaddr iotlb; - - if (memory_region_is_ram(section->mr)) { - /* Normal RAM. */ - iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; - } else { - AddressSpaceDispatch *d; - - d =3D flatview_to_dispatch(section->fv); - iotlb =3D section - d->map.sections; - iotlb +=3D xlat; - } - - return iotlb; + AddressSpaceDispatch *d =3D flatview_to_dispatch(section->fv); + return section - d->map.sections; } #endif /* defined(CONFIG_USER_ONLY) */ =20 --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125389; cv=none; d=zoho.com; s=zohoarc; b=iSpvBxCxkCm48Mwwfc8vwJvtT+KS+pDvoF4YMyK22Iej6UhpPv5DyC6ug7xtCZh1oYyWxj8sojPcNM1foXVQ4fnrYN50gp9AdVi/XufloA5D06FVQCfAcbpTgctZbuYaO8MeGGI8u08xGMstSQGwwvDIlZyhtzPvqor/ZSZTX9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125389; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=49dRujykpdSXqDpMsXZ6b2BPb+ubAPTXZdHimZ2XaMo=; b=Etome9WVq5yBPD22s2S5q8YVnb6Zgt0h7xRrJsbMeFGBbExOZt4jYf2kJqk+kKQfxyzjZ48DXVwoy3vNUcHiAo5+eZ/kqgersqFvxJSqmzeHOrCMeSSXf3blKCBGWXjjqrICqXUu1Hxpgrr1xTf1Wb+p5j5zRd3A5d3+f7sRXzg= 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 1569125389330194.4881537042204; Sat, 21 Sep 2019 21:09:49 -0700 (PDT) Received: from localhost ([::1]:45058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtBz-00072r-Rt for importer@patchew.org; Sun, 22 Sep 2019 00:09:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40955) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy3-0001qm-Uq for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsy1-0008JG-GW for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:23 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34347) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsy1-0008Ip-7K for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:21 -0400 Received: by mail-pf1-x441.google.com with SMTP id b128so7003212pfa.1 for ; Sat, 21 Sep 2019 20:55:21 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:18 -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=49dRujykpdSXqDpMsXZ6b2BPb+ubAPTXZdHimZ2XaMo=; b=B6s6BW4WpagI+Iinjvq0hstwAHHDof3ua6qMfrz3QIHwv5KiIafB0vyc2gD/9AQaA8 H47qXXMloGakgK5QH6B/d8/R9NJE18SPOgJS/LSayRX4Inr/JvS9L+GtB9SVmtlp+R+z AMPL8nvWTeZk1/pkNbFsb77TtQSymODuz2q1U1KJLWWGhsw05CW74Td6/vJdrr7Fc5Ig WCI/jLyWG0fhwG8C5LsiGK/h+bXwueRkDWCQTSwFhD5IlWTX9CLOwa3lRF2H4CiQNi1k QFmQv7UceEO6nrnNZFcagBRD48YksUi3q0ubmzbLGPU5oQh4JJFwQ8g/+JS/IBr9e1Pl pQ2g== 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=49dRujykpdSXqDpMsXZ6b2BPb+ubAPTXZdHimZ2XaMo=; b=KKLhfbnc1lzsHc+w7PzkD8dqEDfTUds24+POmwGmUobV8pwIU6Kn1NC1kV3yP34pCA JKOMqhtvirViJ7hrExKZwC9psWBkHuwoAFtj9OWs4fQiLE+bgK6Y+ZuGcpwCRGTuNODF 1j4a3TRR6X3Yr4zN2EhNOa16nMrjWHB5acZeV/j+9cYt5IVxXb6ZtpRRzk0N9UkDLrhy wWUgD5a0jD/pI8L+/jL0nsnLxh85co8hmfDsKEv16U0fsVflzQK1Qd+d0TQN8U15G8MR WY9rJCAwdr9F9qKQE0xbPEXM5PlIzDtohanBfatOzmjfJcqpnQKwa/IVK5I1LK6Utb2g 1Mrg== X-Gm-Message-State: APjAAAVqIxeQt7XaewoMzXAQteK27uR0s8NoFprrieMORkoMkjevqGpw joGrTZ+5hZr36uIoH/WDTjPk09AWdHM= X-Google-Smtp-Source: APXvYqwNLW8esnopzsXANGX7MliCzhNlwb4zFgKUSg7BTSoAyVgkQTVliYJLRUo5vPV3IX/jHBJuaQ== X-Received: by 2002:a63:6193:: with SMTP id v141mr23476545pgb.263.1569124519791; Sat, 21 Sep 2019 20:55:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/20] cputlb: Merge and move memory_notdirty_write_{prepare, complete} Date: Sat, 21 Sep 2019 20:54:53 -0700 Message-Id: <20190922035458.14879-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::441 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since 9458a9a1df1a, all readers of the dirty bitmaps wait for the rcu lock, which means that they wait until the end of any executing TranslationBlock. As a consequence, there is no need for the actual access to happen in between the _prepare and _complete. Therefore, we can improve things by merging the two functions into notdirty_write and dropping the NotDirtyInfo structure. In addition, the only users of notdirty_write are in cputlb.c, so move the merged function there. Pass in the CPUIOTLBEntry from which the ram_addr_t may be computed. Signed-off-by: Richard Henderson --- include/exec/memory-internal.h | 65 ----------------------------- accel/tcg/cputlb.c | 76 +++++++++++++++++++--------------- exec.c | 44 -------------------- 3 files changed, 42 insertions(+), 143 deletions(-) diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index ef4fb92371..9fcc2af25c 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -49,70 +49,5 @@ void address_space_dispatch_free(AddressSpaceDispatch *d= ); =20 void mtree_print_dispatch(struct AddressSpaceDispatch *d, MemoryRegion *root); - -struct page_collection; - -/* Opaque struct for passing info from memory_notdirty_write_prepare() - * to memory_notdirty_write_complete(). Callers should treat all fields - * as private, with the exception of @active. - * - * @active is a field which is not touched by either the prepare or - * complete functions, but which the caller can use if it wishes to - * track whether it has called prepare for this struct and so needs - * to later call the complete function. - */ -typedef struct { - CPUState *cpu; - struct page_collection *pages; - ram_addr_t ram_addr; - vaddr mem_vaddr; - unsigned size; - bool active; -} NotDirtyInfo; - -/** - * memory_notdirty_write_prepare: call before writing to non-dirty memory - * @ndi: pointer to opaque NotDirtyInfo struct - * @cpu: CPU doing the write - * @mem_vaddr: virtual address of write - * @ram_addr: the ram address of the write - * @size: size of write in bytes - * - * Any code which writes to the host memory corresponding to - * guest RAM which has been marked as NOTDIRTY must wrap those - * writes in calls to memory_notdirty_write_prepare() and - * memory_notdirty_write_complete(): - * - * NotDirtyInfo ndi; - * memory_notdirty_write_prepare(&ndi, ....); - * ... perform write here ... - * memory_notdirty_write_complete(&ndi); - * - * These calls will ensure that we flush any TCG translated code for - * the memory being written, update the dirty bits and (if possible) - * remove the slowpath callback for writing to the memory. - * - * This must only be called if we are using TCG; it will assert otherwise. - * - * We may take locks in the prepare call, so callers must ensure that - * they don't exit (via longjump or otherwise) without calling complete. - * - * This call must only be made inside an RCU critical section. - * (Note that while we're executing a TCG TB we're always in an - * RCU critical section, which is likely to be the case for callers - * of these functions.) - */ -void memory_notdirty_write_prepare(NotDirtyInfo *ndi, - CPUState *cpu, - vaddr mem_vaddr, - ram_addr_t ram_addr, - unsigned size); -/** - * memory_notdirty_write_complete: finish write to non-dirty memory - * @ndi: pointer to the opaque NotDirtyInfo struct which was initialized - * by memory_not_dirty_write_prepare(). - */ -void memory_notdirty_write_complete(NotDirtyInfo *ndi); - #endif #endif diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 1a839c0f82..6f685cb93a 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -33,6 +33,7 @@ #include "exec/helper-proto.h" #include "qemu/atomic.h" #include "qemu/atomic128.h" +#include "translate-all.h" =20 /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ @@ -1084,6 +1085,37 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env,= target_ulong addr) return qemu_ram_addr_from_host_nofail(p); } =20 +static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size, + CPUIOTLBEntry *iotlbentry, uintptr_t retaddr) +{ + ram_addr_t ram_addr =3D mem_vaddr + iotlbentry->addr; + + trace_memory_notdirty_write_access(mem_vaddr, ram_addr, size); + + if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { + struct page_collection *pages + =3D page_collection_lock(ram_addr, ram_addr + size); + + /* We require mem_io_pc in tb_invalidate_phys_page_range. */ + cpu->mem_io_pc =3D retaddr; + + tb_invalidate_phys_page_fast(pages, ram_addr, size); + page_collection_unlock(pages); + } + + /* + * Set both VGA and migration bits for simplicity and to remove + * the notdirty callback faster. + */ + cpu_physical_memory_set_dirty_range(ram_addr, size, DIRTY_CLIENTS_NOCO= DE); + + /* We remove the notdirty callback only if the code has been flushed. = */ + if (!cpu_physical_memory_is_clean(ram_addr)) { + trace_memory_notdirty_set_dirty(mem_vaddr); + tlb_set_dirty(cpu, mem_vaddr); + } +} + /* * Probe for whether the specified guest access is permitted. If it is not * permitted then an exception will be taken in the same way as if this @@ -1203,8 +1235,7 @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr ad= dr, /* Probe for a read-modify-write atomic operation. Do not allow unaligned * operations, or io operations to proceed. Return the host address. */ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, - TCGMemOpIdx oi, uintptr_t retaddr, - NotDirtyInfo *ndi) + TCGMemOpIdx oi, uintptr_t retaddr) { size_t mmu_idx =3D get_mmuidx(oi); uintptr_t index =3D tlb_index(env, mmu_idx, addr); @@ -1264,12 +1295,9 @@ static void *atomic_mmu_lookup(CPUArchState *env, ta= rget_ulong addr, =20 hostaddr =3D (void *)((uintptr_t)addr + tlbe->addend); =20 - ndi->active =3D false; if (unlikely(tlb_addr & TLB_NOTDIRTY)) { - ndi->active =3D true; - memory_notdirty_write_prepare(ndi, env_cpu(env), addr, - qemu_ram_addr_from_host_nofail(hosta= ddr), - 1 << s_bits); + notdirty_write(env_cpu(env), addr, 1 << s_bits, + &env_tlb(env)->d[mmu_idx].iotlb[index], retaddr); } =20 return hostaddr; @@ -1635,28 +1663,13 @@ store_helper(CPUArchState *env, target_ulong addr, = uint64_t val, return; } =20 - haddr =3D (void *)((uintptr_t)addr + entry->addend); - /* Handle clean RAM pages. */ if (tlb_addr & TLB_NOTDIRTY) { - NotDirtyInfo ndi; - - /* We require mem_io_pc in tb_invalidate_phys_page_range. */ - env_cpu(env)->mem_io_pc =3D retaddr; - - memory_notdirty_write_prepare(&ndi, env_cpu(env), addr, - addr + iotlbentry->addr, size); - - if (unlikely(tlb_addr & TLB_BSWAP)) { - direct_swap(haddr, val); - } else { - direct(haddr, val); - } - - memory_notdirty_write_complete(&ndi); - return; + notdirty_write(env_cpu(env), addr, size, iotlbentry, retaddr); } =20 + haddr =3D (void *)((uintptr_t)addr + entry->addend); + if (unlikely(tlb_addr & TLB_BSWAP)) { direct_swap(haddr, val); } else { @@ -1786,14 +1799,9 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulo= ng addr, uint64_t val, #define EXTRA_ARGS , TCGMemOpIdx oi, uintptr_t retaddr #define ATOMIC_NAME(X) \ HELPER(glue(glue(glue(atomic_ ## X, SUFFIX), END), _mmu)) -#define ATOMIC_MMU_DECLS NotDirtyInfo ndi -#define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, retaddr, &ndi) -#define ATOMIC_MMU_CLEANUP \ - do { \ - if (unlikely(ndi.active)) { \ - memory_notdirty_write_complete(&ndi); \ - } \ - } while (0) +#define ATOMIC_MMU_DECLS +#define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, retaddr) +#define ATOMIC_MMU_CLEANUP =20 #define DATA_SIZE 1 #include "atomic_template.h" @@ -1821,7 +1829,7 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulon= g addr, uint64_t val, #undef ATOMIC_MMU_LOOKUP #define EXTRA_ARGS , TCGMemOpIdx oi #define ATOMIC_NAME(X) HELPER(glue(glue(atomic_ ## X, SUFFIX), END)) -#define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, GETPC(), &ndi) +#define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, GETPC()) =20 #define DATA_SIZE 1 #include "atomic_template.h" diff --git a/exec.c b/exec.c index 9c9cc811b3..090bcc05da 100644 --- a/exec.c +++ b/exec.c @@ -2684,50 +2684,6 @@ ram_addr_t qemu_ram_addr_from_host(void *ptr) return block->offset + offset; } =20 -/* Called within RCU critical section. */ -void memory_notdirty_write_prepare(NotDirtyInfo *ndi, - CPUState *cpu, - vaddr mem_vaddr, - ram_addr_t ram_addr, - unsigned size) -{ - ndi->cpu =3D cpu; - ndi->ram_addr =3D ram_addr; - ndi->mem_vaddr =3D mem_vaddr; - ndi->size =3D size; - ndi->pages =3D NULL; - - trace_memory_notdirty_write_access(mem_vaddr, ram_addr, size); - - assert(tcg_enabled()); - if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { - ndi->pages =3D page_collection_lock(ram_addr, ram_addr + size); - tb_invalidate_phys_page_fast(ndi->pages, ram_addr, size); - } -} - -/* Called within RCU critical section. */ -void memory_notdirty_write_complete(NotDirtyInfo *ndi) -{ - if (ndi->pages) { - assert(tcg_enabled()); - page_collection_unlock(ndi->pages); - ndi->pages =3D NULL; - } - - /* Set both VGA and migration bits for simplicity and to remove - * the notdirty callback faster. - */ - cpu_physical_memory_set_dirty_range(ndi->ram_addr, ndi->size, - DIRTY_CLIENTS_NOCODE); - /* we remove the notdirty callback only if the code has been - flushed */ - if (!cpu_physical_memory_is_clean(ndi->ram_addr)) { - trace_memory_notdirty_set_dirty(ndi->mem_vaddr); - tlb_set_dirty(ndi->cpu, ndi->mem_vaddr); - } -} - /* Generate a debug exception if a watchpoint has been hit. */ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, MemTxAttrs attrs, int flags, uintptr_t ra) --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125574; cv=none; d=zoho.com; s=zohoarc; b=bFr6bqP38zxzY2Nog7zSdIUGJMctm20irH4ImCW0i5QRP1YD7TDtKy81DCD4RqOBXAiLQ2Cu9LzjF8HcGB+WzPChbqJygYDuX83lfjw+Wfcea3VYbaBq9HX9lhDBMTKqFHhmTiPouruli/Pub+SZ6sHMD+3VH1eRyE6NPEg2pyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125574; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zEd6YE2E51WcAYpdL1J80c/c4YK3movqIfz5U+RR1Wo=; b=iwNBgfGAn92i7FXjeZ4NkNN4Efs6rGuj37DY2u8lsQyyWJCKS1TNdn3hJk6gpPTF5z66KPGs2vfavAvPkmfKJdUI4LwQUhWVj+kBL/8iifQ6di563ga7jw3DAb3Y7SGboTXGgcfMJz1m/CZBgC+u5k8rEy0K68ruvIncQe2lqKw= 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 156912557441185.05630767366972; Sat, 21 Sep 2019 21:12:54 -0700 (PDT) Received: from localhost ([::1]:45104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtEz-0002Cc-4Q for importer@patchew.org; Sun, 22 Sep 2019 00:12:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40956) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy3-0001qo-Vo for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsy2-0008KB-Na for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:23 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:45440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsy2-0008JT-Gl for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:22 -0400 Received: by mail-pl1-x642.google.com with SMTP id u12so4953598pls.12 for ; Sat, 21 Sep 2019 20:55:22 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:20 -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=zEd6YE2E51WcAYpdL1J80c/c4YK3movqIfz5U+RR1Wo=; b=ahPTAEdLS/CFjPoKB2eUVHeIexGBLL6i3O33ZfdtOPD7FfG303LYID/k7GkUc//OIz jBycjRCZ7WSPvxjAhPYiv6rtS/95UqurvzUQdZjDhEyHH/Y2HaJfvF/iPDGOPIHCvufA Wah6xUW4IEBvExcBWZzJNEVbG8B89A+XaNgT7UHb7apmJ44c8VxyjHGIYTIQt91ofm9x Fk+pwxp75JT1qOrCQ6MoXgW1Rmpiv3sPw0wTRaPgwUCGD9xGdGBORN1Yt1mb2nRHUldj Djy611wWfxKDD56x7hxKhz7GGzjM3IiCEgcusSgaNQ+60QI4STU+NY8yH7JPBI09nyNc /cxw== 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=zEd6YE2E51WcAYpdL1J80c/c4YK3movqIfz5U+RR1Wo=; b=dKimr+AN18NfmZZb3DBB9m+91lrluLX7dhTJUW8az0IFo07vVKr+HjcJqHGGUNGJWJ Uqa0e3ufRHUYGh3J+K936gR0jxdm31Q8CJVSArNVSi9h4/U2h/Lcjzq5byr7FAQU8lDU je8kUPGhV3p6BRJJCbS9xaKx/Ie8DrXRHDyiI5smI5c8y6ui6d2EkgO2pnC8LftsbaLz ZOxH2xTdkv9M2gaPzvqoLexS5MHQ+I+YgHOUX8p846tI6JiJXx9gGpuF+Xus1qAVa0ls X0EqQS7dTLS4j21G3F2Rvfje8M3Cz1yMtNjzPniUMcAGTaMvvH+duQRiwV4Vb/oks25f pT8w== X-Gm-Message-State: APjAAAVhfv09eEf9z5jHTzMFlZFjJXj7Y8xjFV3pe0fLDNV0wJiM+PSC CPsdyH5XJ3CgBWO83iswXyZ5IWcGJKk= X-Google-Smtp-Source: APXvYqzSE8M5fWbBBDrlvprdOb8HjuYi2T2ERdExmvR2v8ilXKNtn2/fQhoLtw6A/ErJnApfThJJ9g== X-Received: by 2002:a17:902:a717:: with SMTP id w23mr3321plq.17.1569124521049; Sat, 21 Sep 2019 20:55:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/20] cputlb: Handle TLB_NOTDIRTY in probe_access Date: Sat, 21 Sep 2019 20:54:54 -0700 Message-Id: <20190922035458.14879-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::642 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We can use notdirty_write for the write and return a valid host pointer for this case. Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 6f685cb93a..6f4096bd0d 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1167,16 +1167,24 @@ void *probe_access(CPUArchState *env, target_ulong = addr, int size, return NULL; } =20 - /* Handle watchpoints. */ - if (tlb_addr & TLB_WATCHPOINT) { - cpu_check_watchpoint(env_cpu(env), addr, size, - env_tlb(env)->d[mmu_idx].iotlb[index].attrs, - wp_access, retaddr); - } + if (unlikely(tlb_addr & TLB_FLAGS_MASK)) { + CPUIOTLBEntry *iotlbentry =3D &env_tlb(env)->d[mmu_idx].iotlb[inde= x]; =20 - /* Reject I/O access, or other required slow-path. */ - if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO | TLB_BSWAP | TLB_ROM)) { - return NULL; + /* Reject I/O access, or other required slow-path. */ + if (tlb_addr & (TLB_MMIO | TLB_BSWAP | TLB_ROM)) { + return NULL; + } + + /* Handle watchpoints. */ + if (tlb_addr & TLB_WATCHPOINT) { + cpu_check_watchpoint(env_cpu(env), addr, size, + iotlbentry->attrs, wp_access, retaddr); + } + + /* Handle clean RAM pages. */ + if (tlb_addr & TLB_NOTDIRTY) { + notdirty_write(env_cpu(env), addr, size, iotlbentry, retaddr); + } } =20 return (void *)((uintptr_t)addr + entry->addend); --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125533; cv=none; d=zoho.com; s=zohoarc; b=PpOZVVbbbAmv+IgMsy0MlO3sy7HEvQ6YJQmTv2mUObfXLxfP0Z34sibDBFErQBQ9BufIDkXZROQAtwus2c48rWMMRKqvqxBo1oQk5PFoNHIX6LlqZkt6lU7LwxidMZi3aAQTpL8xwwWzMhlrM1LT0w3HFzV/pgVi2QOwDnsfqiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125533; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ToVeCrPKjDs8wNyDQYleTQmt7ApWfc5+CUsaiKNo26w=; b=El7WASVIcC1rEC/kOQ+N6TCLHumMzrN8m7WF/WgAzJ+9DyTpeizgGdtid2gu2OiWVuTQleJccKGT/qrlg/QrfBMRM+Pe1pKr8RM6RaBti4qYraM7j4p3LUPuYD8/SJFaTzis7nbaW7QIb11KaOEAPFPV82wFpHKAy1G44aQKJsc= 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 1569125533652816.0397009029854; Sat, 21 Sep 2019 21:12:13 -0700 (PDT) Received: from localhost ([::1]:45096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtEG-0001OV-Bc for importer@patchew.org; Sun, 22 Sep 2019 00:12:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40970) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy5-0001tc-Bd for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsy3-0008Kt-Sx for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:25 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44556) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsy3-0008KT-LZ for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:23 -0400 Received: by mail-pl1-x642.google.com with SMTP id q15so4954379pll.11 for ; Sat, 21 Sep 2019 20:55:23 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:21 -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=ToVeCrPKjDs8wNyDQYleTQmt7ApWfc5+CUsaiKNo26w=; b=m0MaqjUYkr9stJiKXjGopdqhG9rTUZy1hB90ac1UPuPjsuJ03RytcMXSvCNrYsEVz4 J/MZyWxQAxNorfzu4UvOooZmoqyPdAIxNT+tM1irVR+WlmV0S6OZYvv/GbCy6UfvtulE gZKUVKDC51+ty9EDvB+TgQ25aMQ79qgMxOJqqdLQZrGNAjcytdsCS3SKbH729CV+51KL B+Ys7SZblMl6vK0TUqxbTUsSvMqrbMOMopHHk2hZiRrQ1vmzZr4/HLsj+5IfUDbS3aKh c9gQnBHyL4VTEF8GLsRxIdgj8Z2NpwEIi/x5NkPOijzhb8DNqB+EDyo7wG1mR1/hVi/i X+UA== 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=ToVeCrPKjDs8wNyDQYleTQmt7ApWfc5+CUsaiKNo26w=; b=sjvEyqtY4J7DZ/wMp1yYlJCgEsAgsD4FoXA2T4qneiPx1nrVySyAtY0damlUjG9lci 5ZyIh/rGLUjpC50ueeV8LsDFCDVatnKLL6TVWTi9DtTesGBzbMyotKnA+kf6ovO/mEBr oRkSj6WLZJoBHBFlG32Q2RO7omzI3eRN/U/Ml3muuYicM9DjftQummbxFGnoNVB59hOG 5sfUrxvYX33BgM5AQ4Sl1cWnIP20O8ZwtRm8iI6vZHaVEN8UnmLkGy9H038c5QuzV+gz ff8bWGnM98lCxtExCKRW0PNrMEYyV7yqZmOuk9NGU8jYFNJTlN2w1FxrK8NeqxhnNv5e o0HQ== X-Gm-Message-State: APjAAAVPzdf+OScSwDtaIuk1moakcAXayy9ei8e0mLmisI0c14Q3s0zp C3Jkoj2+6/ZNndk8txMyj4oGcECOp/A= X-Google-Smtp-Source: APXvYqzFPUd20hgQixKWWc0r1tmUH49sVgX+BGPxuuP6532s1e3YVbTIQ5XlEUbT34trnYuYhAZpvA== X-Received: by 2002:a17:902:426:: with SMTP id 35mr25954265ple.192.1569124522370; Sat, 21 Sep 2019 20:55:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 17/20] cputlb: Remove cpu->mem_io_vaddr Date: Sat, 21 Sep 2019 20:54:55 -0700 Message-Id: <20190922035458.14879-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::642 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" With the merge of notdirty handling into store_helper, the last user of cpu->mem_io_vaddr was removed. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- include/hw/core/cpu.h | 2 -- accel/tcg/cputlb.c | 2 -- hw/core/cpu.c | 1 - 3 files changed, 5 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c7cda65c66..031f587e51 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -338,7 +338,6 @@ struct qemu_work_item; * @next_cpu: Next CPU sharing TB cache. * @opaque: User data. * @mem_io_pc: Host Program Counter at which the memory was accessed. - * @mem_io_vaddr: Target virtual address at which the memory was accessed. * @kvm_fd: vCPU file descriptor for KVM. * @work_mutex: Lock to prevent multiple access to queued_work_*. * @queued_work_first: First asynchronous work pending. @@ -413,7 +412,6 @@ struct CPUState { * we store some rarely used information in the CPU context. */ uintptr_t mem_io_pc; - vaddr mem_io_vaddr; /* * This is only needed for the legacy cpu_unassigned_access() hook; * when all targets using it have been converted to use diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 6f4096bd0d..257c59c08c 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -927,7 +927,6 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, cpu_io_recompile(cpu, retaddr); } =20 - cpu->mem_io_vaddr =3D addr; cpu->mem_io_access_type =3D access_type; =20 if (mr->global_locking && !qemu_mutex_iothread_locked()) { @@ -967,7 +966,6 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry = *iotlbentry, if (!cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } - cpu->mem_io_vaddr =3D addr; cpu->mem_io_pc =3D retaddr; =20 if (mr->global_locking && !qemu_mutex_iothread_locked()) { diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 0035845511..73b1ee34d0 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -261,7 +261,6 @@ static void cpu_common_reset(CPUState *cpu) cpu->interrupt_request =3D 0; cpu->halted =3D 0; cpu->mem_io_pc =3D 0; - cpu->mem_io_vaddr =3D 0; cpu->icount_extra =3D 0; atomic_set(&cpu->icount_decr_ptr->u32, 0); cpu->can_do_io =3D 1; --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125675; cv=none; d=zoho.com; s=zohoarc; b=hGzQc0HX5fx9Es/szbfTJO5WnRNvJdMa+U5et1Lsv9FPWO0r3oM/eIykHrecnG/F9VjOS40XPTynLb9dMrbO2iqpoegpK20Gnf8zmsJhA9WssFVSGobDOJBvBVzs+fpq2ZP0xETD4LnSoea5RparV39No08lLfty7+AlyaDWVGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125675; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ss7y4dx7Ozqbb6/ZwGCVABLVohdKahfSvIHor1C9aWE=; b=ZI1m0QXwn9zURlcOJRcFZbHm3sPCpaDE2BlKUJaWIxi2WmohzG5WayiVqWot+7PU59uij/GiUW9egu8xiEr/PSxbKaeLpCBRwPPXAafuSB7cJQ17ey7L0U+hg2BrbshoXPUaDiSZE5Uuy1isV15n7n9hFj4tLIP3XXBumw/asJU= 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 156912567533241.078382065219785; Sat, 21 Sep 2019 21:14:35 -0700 (PDT) Received: from localhost ([::1]:45146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtGc-00049d-C5 for importer@patchew.org; Sun, 22 Sep 2019 00:14:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40983) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy6-0001wH-Bw for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsy5-0008Lm-0L for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:26 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:41685) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsy4-0008LI-PE for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:24 -0400 Received: by mail-pl1-x641.google.com with SMTP id t10so4964599plr.8 for ; Sat, 21 Sep 2019 20:55:24 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:22 -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=Ss7y4dx7Ozqbb6/ZwGCVABLVohdKahfSvIHor1C9aWE=; b=mR1Po/VFhedo64cklbQLJtV7ILp2Doi8K3Aey46xzAvTpRclB+hCWfpDiae31WELk7 Ft22XvMFWbnX5nQvO8H6fN6Px5Jv+Af4dN+d5Aa9IXvnzpRTS37vLzNuEjuRHD1BDzCO xqifaw7UBHGvkoql1fuWNPwXqkqqPWFm7ECCHiNvX7lj3PT7fir8KqL7EnMeW2GeljKF MyxCvbAtGwViD+DiyF1bh6JwvsOD9r/0b6PwNQ7V5RkPMidL/qo1B366KoGGzreEI8a7 x+JGB2JgunXxqlL2bZIuMyU6iyaODzGj58uHphKz6ClAusoj+SPlATmCxSZQ8iVPRCu3 3yKg== 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=Ss7y4dx7Ozqbb6/ZwGCVABLVohdKahfSvIHor1C9aWE=; b=flwGlg8OJedNn0ib3fSLpOEj5blDFCFKJURbEwadsyDeZn6aknRVSpTIG7ihsLXAan iiRUqwfxfZwJ5fwppjE3n3IqSbT6QCItfRtixcrywruN58WC2C223LZQOQYp1UBBT9ow O71nX5/HhKtTT+Ok8KmGEp89BITPgdJPNwWi/r1JeGU/lhyefTIGvqBG834Gsn+b0ZZI AGpwesfywOzzfWk9ZiNpBEIe0d8itzsQY9vjdfA16oibhCQqw2lRfXtzEO0siWfgOiyl ftjDGeenmR+4J4NYJdiNclON+FzzUvZpzGw3V3hN6+4ftt3vnzNkTRXl8DvqAF0rnHO2 k6lg== X-Gm-Message-State: APjAAAW8w/6mdHfjzWNOIwyUMd+OUnrRMCTEPaecmaubgIwaH1yWK7Gt ZYzBY6QKsD5dVTCZ8S59XSOQJwPouPs= X-Google-Smtp-Source: APXvYqxGP0fYPzAjHte0+MY7WeOnjdkAYrCSYxEG811+hCQoTjbbhg5+wAzN0KVF6tcQz8fU8SxnoA== X-Received: by 2002:a17:902:fe86:: with SMTP id x6mr25554899plm.28.1569124523489; Sat, 21 Sep 2019 20:55:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/20] cputlb: Remove tb_invalidate_phys_page_range is_cpu_write_access Date: Sat, 21 Sep 2019 20:54:56 -0700 Message-Id: <20190922035458.14879-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::641 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All callers pass false to this argument. Remove it and pass the constant on to tb_invalidate_phys_page_range__locked. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- accel/tcg/translate-all.h | 3 +-- accel/tcg/translate-all.c | 6 ++---- exec.c | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/accel/tcg/translate-all.h b/accel/tcg/translate-all.h index 64f5fd9a05..31f2117188 100644 --- a/accel/tcg/translate-all.h +++ b/accel/tcg/translate-all.h @@ -28,8 +28,7 @@ struct page_collection *page_collection_lock(tb_page_addr= _t start, void page_collection_unlock(struct page_collection *set); void tb_invalidate_phys_page_fast(struct page_collection *pages, tb_page_addr_t start, int len); -void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d, - int is_cpu_write_access); +void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d); void tb_check_watchpoint(CPUState *cpu); =20 #ifdef CONFIG_USER_ONLY diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 5d1e08b169..de4b697163 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1983,8 +1983,7 @@ tb_invalidate_phys_page_range__locked(struct page_col= lection *pages, * * Called with mmap_lock held for user-mode emulation */ -void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d, - int is_cpu_write_access) +void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d) { struct page_collection *pages; PageDesc *p; @@ -1996,8 +1995,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t sta= rt, tb_page_addr_t end, return; } pages =3D page_collection_lock(start, end); - tb_invalidate_phys_page_range__locked(pages, p, start, end, - is_cpu_write_access); + tb_invalidate_phys_page_range__locked(pages, p, start, end, 0); page_collection_unlock(pages); } =20 diff --git a/exec.c b/exec.c index 090bcc05da..fed25d029b 100644 --- a/exec.c +++ b/exec.c @@ -978,7 +978,7 @@ const char *parse_cpu_option(const char *cpu_option) void tb_invalidate_phys_addr(target_ulong addr) { mmap_lock(); - tb_invalidate_phys_page_range(addr, addr + 1, 0); + tb_invalidate_phys_page_range(addr, addr + 1); mmap_unlock(); } =20 @@ -1005,7 +1005,7 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr= addr, MemTxAttrs attrs) return; } ram_addr =3D memory_region_get_ram_addr(mr) + addr; - tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0); + tb_invalidate_phys_page_range(ram_addr, ram_addr + 1); rcu_read_unlock(); } =20 --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125549; cv=none; d=zoho.com; s=zohoarc; b=Me5cevJBnr0uhIK5P1yh3a5PUo7jHRBjgZcBqq66+eQEqVET1TTYeDp+dv9h6UJ9UqXRbuGf7rnCiSSqtLD3LetKldZ5yux0DZmqSTdT8AzpNvE5Kd2L+DiJ4iX/7jggPgFXarGMpD9CsXEKwDhwqYGwbCs+liZsYvF8s9QB7F4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125549; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sDuc8EGRNaTml8IZLkfOWC9uf/uHcOoeKSMXRUSHBtA=; b=NFJvAOi5LKsIkE9qY8XagqrAsDc2vpsHpj1oE+k7vchP/GLCGKJP65G/MK29h+/IwAxILM5EftzS3PXHi7bO4Pun++uwja2jzSt89uZiIHva/ytekA0QsSTl0DNX3lv79S74u0zzT+JCCVp8Gar9Y0c29vcBZ2yoXmVqkIYuu2A= 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 1569125549469278.9753623509374; Sat, 21 Sep 2019 21:12:29 -0700 (PDT) Received: from localhost ([::1]:45100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtEa-0001cQ-6g for importer@patchew.org; Sun, 22 Sep 2019 00:12:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40998) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy8-0001yr-6H for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsy6-0008Mb-Qd for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:28 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:43463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsy6-0008MK-Jy for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:26 -0400 Received: by mail-pg1-x543.google.com with SMTP id d4so2902118pgd.10 for ; Sat, 21 Sep 2019 20:55:26 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:24 -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=sDuc8EGRNaTml8IZLkfOWC9uf/uHcOoeKSMXRUSHBtA=; b=DTJ4aK9HwfKrjitfJTj/ZwefS8YvEmDtxQuoM2xXoflI9QZegGjQVE4hXF5ZmdQ/Td J0dZuy0n4+h2h+Q6bN+OuzaQhAuuMpLKkdvA2Fu/IzUCmHuHH/XYqVJ5hlE1KYB2PVu9 q9nhn81yGoTXK1MulaPB8q1LtdSmaPTyT0p5f782J4tQO+CpdUN4psvzUU7BxTvCYT7T WgbpTSCLFCzQVcmPyOybGQtZ3kXyEsUSpYqsbi8gWlW/1V/ZAJk/l8WZry4wl8AVxZBc 9qSdbw3fg0kYomqTLghP3WZySkQWnE4QiFNByE4sU5jkeVuX4m7+1BuodMwOwt8oRGfV xFJw== 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=sDuc8EGRNaTml8IZLkfOWC9uf/uHcOoeKSMXRUSHBtA=; b=KmFw1M6uhKdYG9nBvlmJTTKA1qe4ARz1Qbx6DBmRSwpFEF8gdrwHRZXa76dQ5NIbQ+ 8zRK63uK4h315V3/RaCXimWxyt3Q5Ce8snO7pNZN1bYXRIndWhXIu4DhMg1IFBMRsILR LMdQ8ZVlm0XnsL0OND6ZoCWoLJI/GtM4ps5u7rUyuGrQc2r6TufWBpsCFP27hCBoI5P8 S2GCLD56BfhfmwUH8IZDWz7bY2WnvkL0Jn2CZ76GEHMQCeOihlIW2NchSajg0xBvabUP rSC12nAE0ssWIUhfD0UvhJ/ebJNR2J8jjiqxjticOv39e0x6Iyyb+cTASK9thU5RzVSa saZQ== X-Gm-Message-State: APjAAAWnxwuJpmR2LeAty1YOS08AbP6tXUrlfct05dXGY4Ug9Pwa4dvr yDI3cQ8nZi8hgDgUG4xN5gjUaTLFsKQ= X-Google-Smtp-Source: APXvYqyMDnR4Fp3xBSyoPWnYNQlMwvx/1WGjO0uazHQkqnht+NjjWkpGBcqAki+OX0nuYAnHWqE6AQ== X-Received: by 2002:a17:90a:a4c6:: with SMTP id l6mr14235314pjw.15.1569124525054; Sat, 21 Sep 2019 20:55:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/20] cputlb: Pass retaddr to tb_invalidate_phys_page_fast Date: Sat, 21 Sep 2019 20:54:57 -0700 Message-Id: <20190922035458.14879-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::543 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Rather than rely on cpu->mem_io_pc, pass retaddr down directly. Within tb_invalidate_phys_page_range__locked, the is_cpu_write_access parameter is non-zero exactly when retaddr would be non-zero, so that is a simple replacement. Recognize that current_tb_not_found is true only when mem_io_pc (and now retaddr) are also non-zero, so remove a redundant test. Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- accel/tcg/translate-all.h | 3 ++- accel/tcg/cputlb.c | 6 +----- accel/tcg/translate-all.c | 39 +++++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/accel/tcg/translate-all.h b/accel/tcg/translate-all.h index 31f2117188..135c1ea96a 100644 --- a/accel/tcg/translate-all.h +++ b/accel/tcg/translate-all.h @@ -27,7 +27,8 @@ struct page_collection *page_collection_lock(tb_page_addr= _t start, tb_page_addr_t end); void page_collection_unlock(struct page_collection *set); void tb_invalidate_phys_page_fast(struct page_collection *pages, - tb_page_addr_t start, int len); + tb_page_addr_t start, int len, + uintptr_t retaddr); void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d); void tb_check_watchpoint(CPUState *cpu); =20 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 257c59c08c..eff129447d 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1093,11 +1093,7 @@ static void notdirty_write(CPUState *cpu, vaddr mem_= vaddr, unsigned size, if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { struct page_collection *pages =3D page_collection_lock(ram_addr, ram_addr + size); - - /* We require mem_io_pc in tb_invalidate_phys_page_range. */ - cpu->mem_io_pc =3D retaddr; - - tb_invalidate_phys_page_fast(pages, ram_addr, size); + tb_invalidate_phys_page_fast(pages, ram_addr, size, retaddr); page_collection_unlock(pages); } =20 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index de4b697163..db77fb221b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1889,7 +1889,7 @@ static void tb_invalidate_phys_page_range__locked(struct page_collection *pages, PageDesc *p, tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access) + uintptr_t retaddr) { TranslationBlock *tb; tb_page_addr_t tb_start, tb_end; @@ -1897,9 +1897,9 @@ tb_invalidate_phys_page_range__locked(struct page_col= lection *pages, #ifdef TARGET_HAS_PRECISE_SMC CPUState *cpu =3D current_cpu; CPUArchState *env =3D NULL; - int current_tb_not_found =3D is_cpu_write_access; + bool current_tb_not_found =3D retaddr !=3D 0; + bool current_tb_modified =3D false; TranslationBlock *current_tb =3D NULL; - int current_tb_modified =3D 0; target_ulong current_pc =3D 0; target_ulong current_cs_base =3D 0; uint32_t current_flags =3D 0; @@ -1931,24 +1931,21 @@ tb_invalidate_phys_page_range__locked(struct page_c= ollection *pages, if (!(tb_end <=3D start || tb_start >=3D end)) { #ifdef TARGET_HAS_PRECISE_SMC if (current_tb_not_found) { - current_tb_not_found =3D 0; - current_tb =3D NULL; - if (cpu->mem_io_pc) { - /* now we have a real cpu fault */ - current_tb =3D tcg_tb_lookup(cpu->mem_io_pc); - } + current_tb_not_found =3D false; + /* now we have a real cpu fault */ + current_tb =3D tcg_tb_lookup(retaddr); } if (current_tb =3D=3D tb && (tb_cflags(current_tb) & CF_COUNT_MASK) !=3D 1) { - /* If we are modifying the current TB, we must stop - its execution. We could be more precise by checking - that the modification is after the current PC, but it - would require a specialized function to partially - restore the CPU state */ - - current_tb_modified =3D 1; - cpu_restore_state_from_tb(cpu, current_tb, - cpu->mem_io_pc, true); + /* + * If we are modifying the current TB, we must stop + * its execution. We could be more precise by checking + * that the modification is after the current PC, but it + * would require a specialized function to partially + * restore the CPU state. + */ + current_tb_modified =3D true; + cpu_restore_state_from_tb(cpu, current_tb, retaddr, true); cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base, ¤t_flags); } @@ -2042,7 +2039,8 @@ void tb_invalidate_phys_range(target_ulong start, tar= get_ulong end) * Call with all @pages in the range [@start, @start + len[ locked. */ void tb_invalidate_phys_page_fast(struct page_collection *pages, - tb_page_addr_t start, int len) + tb_page_addr_t start, int len, + uintptr_t retaddr) { PageDesc *p; =20 @@ -2069,7 +2067,8 @@ void tb_invalidate_phys_page_fast(struct page_collect= ion *pages, } } else { do_invalidate: - tb_invalidate_phys_page_range__locked(pages, p, start, start + len= , 1); + tb_invalidate_phys_page_range__locked(pages, p, start, start + len, + retaddr); } } #else --=20 2.17.1 From nobody Thu May 2 01:42:39 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=1569125761; cv=none; d=zoho.com; s=zohoarc; b=CPvNO1yBg2qT9nJyWnY658FdSZ04OMXVe/2Li5VR4hZeQUBFx/ErtEAq7xf+DrEMrGdv7TJH7wLzaKWvij6IgStBmVGSiiXmF6z/gy0yfRd0N6w52WGN1YlNhzd8bPXQP4w+GyTaKEY3ECEDeagM7OUFRswp8dreTNqKBSNUp78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569125761; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kZbTTJGGFu81f0ejGjFeWXy3vD4smmCaoq9ERb/1yZk=; b=F93ZZiQrg956/fp/NR0G59D2O2Mko/jjBrHwPp7x8RokXIA6zeIqIRYtWftHBzdnfpLNVZAbxA/86cmDK+1FxecBHZFxStNOFCBEmRq1FwSKZfkN/bw89hDUaBm0LCNEG7x0xnF1PA9sQrIiOsZN4BDuulfA5kIlCllhhxcz41A= 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 1569125761880837.5893689360041; Sat, 21 Sep 2019 21:16:01 -0700 (PDT) Received: from localhost ([::1]:45178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtI0-0005fq-EJ for importer@patchew.org; Sun, 22 Sep 2019 00:16:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41005) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy8-000205-VL for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsy7-0008N2-P7 for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:28 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:41016) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsy7-0008MY-J3 for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:27 -0400 Received: by mail-pf1-x442.google.com with SMTP id q7so6974798pfh.8 for ; Sat, 21 Sep 2019 20:55:27 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:25 -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=kZbTTJGGFu81f0ejGjFeWXy3vD4smmCaoq9ERb/1yZk=; b=YLHucrYFMviJNmlYZ/QnUNsCjp/v/VFyvhNa/tNx7v2jtAE5mwCOaZZUOiD8dUDZDm jcQiz1KLWWUOB2RommGkSQljhz3xRjEwzNsSFwIV8y5NUhJFpYVIJGYBXWm5axLQGL6s +if1gOlVBMH7G1HLLY4PHkM6X2kwHqz8L8YXpb+syGAWusb+XfH+vB0LUmjwtCZu4kAW 9xbOKINboU4+NG7IXjiGVIc9RRB5TbaLwTRUcgREDYSMiybrBlj2+XReruREnqQCA2Se Phd3SvY25j9iw7oYrTcIR6HYhdDBQ13A5McD6n47VLQMUWZFXewkCwiB7v/YDpSLan6Q LTOg== 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=kZbTTJGGFu81f0ejGjFeWXy3vD4smmCaoq9ERb/1yZk=; b=iLzpNQjJrfpw9nXhEYbLDW8l/rxOmljMKPhFBoQHmTHkF5+OcVmLg4Wqk83TW9PKWZ OxYMh5wD5PODFS9O3aw694nIouo9JeaE7wrTwdv3BQGSDlOZDWBE8ixGQYhYwqprXkCp dEYIU/6Nd0JRJDHRD3erDrH2Id9gbYC2tLKsUDmzUZV+NxIkLfEJzQQQQwryyuNfg5r6 yD83Pv+9mTVYVIuu7kTTnetOhSeLEfY7RibKsEOXQ+1nAPtY2C8wawK6WdfFhnlInvcR LICK4fb7dV2WS6pU8ZdqiihwFT0wmy9N8SIAtwbLJcjtsguY0oxxma6J9JE3fAIsvuP6 EQcg== X-Gm-Message-State: APjAAAXv0AT0sI5vE6/CLDA62x8eBJYLlvQEM+Ib06B23GE9tchejwtL A4GnOFRbYr6wTTc0Q1Y6qcsDPoIAXsg= X-Google-Smtp-Source: APXvYqyWNdq0wnjge3LKZ+3BBax+d+Y58SqQ3JwPDN/gp6w2pZEUrw4qx09j2wYU3EozkCQMAUwEZg== X-Received: by 2002:a63:31d8:: with SMTP id x207mr23008887pgx.428.1569124526008; Sat, 21 Sep 2019 20:55:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/20] cputlb: Pass retaddr to tb_check_watchpoint Date: Sat, 21 Sep 2019 20:54:58 -0700 Message-Id: <20190922035458.14879-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::442 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Fixes the previous TLB_WATCHPOINT patches because we are currently failing to set cpu->mem_io_pc with the call to cpu_check_watchpoint. Pass down the retaddr directly because it's readily available. Fixes: 50b107c5d61 Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand --- accel/tcg/translate-all.h | 2 +- accel/tcg/translate-all.c | 6 +++--- exec.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translate-all.h b/accel/tcg/translate-all.h index 135c1ea96a..a557b4e2bb 100644 --- a/accel/tcg/translate-all.h +++ b/accel/tcg/translate-all.h @@ -30,7 +30,7 @@ void tb_invalidate_phys_page_fast(struct page_collection = *pages, tb_page_addr_t start, int len, uintptr_t retaddr); void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d); -void tb_check_watchpoint(CPUState *cpu); +void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr); =20 #ifdef CONFIG_USER_ONLY int page_unprotect(target_ulong address, uintptr_t pc); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index db77fb221b..66d4bc4341 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2142,16 +2142,16 @@ static bool tb_invalidate_phys_page(tb_page_addr_t = addr, uintptr_t pc) #endif =20 /* user-mode: call with mmap_lock held */ -void tb_check_watchpoint(CPUState *cpu) +void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr) { TranslationBlock *tb; =20 assert_memory_lock(); =20 - tb =3D tcg_tb_lookup(cpu->mem_io_pc); + tb =3D tcg_tb_lookup(retaddr); if (tb) { /* We can use retranslation to find the PC. */ - cpu_restore_state_from_tb(cpu, tb, cpu->mem_io_pc, true); + cpu_restore_state_from_tb(cpu, tb, retaddr, true); tb_phys_invalidate(tb, -1); } else { /* The exception probably happened in a helper. The CPU state sho= uld diff --git a/exec.c b/exec.c index fed25d029b..ceeef4cd4b 100644 --- a/exec.c +++ b/exec.c @@ -2724,7 +2724,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, = vaddr len, cpu->watchpoint_hit =3D wp; =20 mmap_lock(); - tb_check_watchpoint(cpu); + tb_check_watchpoint(cpu, ra); if (wp->flags & BP_STOP_BEFORE_ACCESS) { cpu->exception_index =3D EXCP_DEBUG; mmap_unlock(); --=20 2.17.1