From patchwork Sat Sep 16 03:29:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 723564 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp710054wro; Fri, 15 Sep 2023 20:37:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyDXFNQNRR0jMq4VlcTr9mjC+qdINVk34C5j1QTGfNjAni0SNeZGb1r54udH/id+XFrS4L X-Received: by 2002:a0c:b399:0:b0:656:30fb:e230 with SMTP id t25-20020a0cb399000000b0065630fbe230mr2920843qve.17.1694835454050; Fri, 15 Sep 2023 20:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694835454; cv=none; d=google.com; s=arc-20160816; b=hT3N2Ej8a28sn9X7MLEpx2V4qAxmWLDPWGO1c1dCGsed0Uz1BLgkMv6qnb+8z6rcIe TgMYipL3qMyavUwIFH5hyWkRiV4LRHdPBG0o9PuEOVzMuNEqD9mGJYkGPJl/OQ3Db/Ug 7lDUs/9dqmyv3UUDTeOrnbvYBCdWTbmgXxM3GTXJmMIP+hdWDaRbIh4pqWJXPLzU4/8h WI0L11y9DT27X/eBN685GvEGWzprolpdeolYJBPMETF2RbAG9avTfSGFxdSoGtcBECa9 YC0ep9Qhvnwdt/Lh2x8FciGF9tN9PtlQbN9oW0RidJZCtEjbYh4oJeewrTtMYcI0TyN2 ZIUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yHjWbAi9btcVTSvND+C/MROFnqLtNDPhov9ERvl3KYw=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=VilptjJuzF4kORIe/c7g1Yn9r9Ej4YIwDS4JQJca8xBewKCs4h7SGZVfANmAaaahGo x2Ikj8fem4KXBcW+52zmy/Z8oiru/oXGLwea4Z7b1U46fQ7vVQ05DxHKuO6+Fw1kQiTi dm2w3NU46ru0/ibzD77lE8mG4JTFy4MVBufA+Gr+IrGjvh6or2KiCU65w+jAZBRFBR0s iFUl+uMgTpMaQJumAPfm5ryx1nfZhZ6gas/TZrLSImtdp4tnx3G1jFynHzzGJzO8Y1+I d9o/9NE6v4zPNPHw2wvO/wdf5JKlU3c/wkEZEPHmpA99yrEMTZZoU2vq/k1TIu8p6JGD u7Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hJrlHofx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t8-20020a0cde08000000b0063d00dc9c52si3221096qvk.471.2023.09.15.20.37.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Sep 2023 20:37:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hJrlHofx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhM15-00064m-Ri; Fri, 15 Sep 2023 23:30:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhM13-00063F-3w for qemu-devel@nongnu.org; Fri, 15 Sep 2023 23:30:41 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhM11-00084S-DK for qemu-devel@nongnu.org; Fri, 15 Sep 2023 23:30:40 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-68fb2e9ebbfso2332785b3a.2 for ; Fri, 15 Sep 2023 20:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694835038; x=1695439838; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yHjWbAi9btcVTSvND+C/MROFnqLtNDPhov9ERvl3KYw=; b=hJrlHofxsOhm0WKr4ETNj/7OXBMBTNDTWs2txFnoY5ZoJRAMZx9JaWqYEGdNiw99KQ geUn0LvQO5ZK9HPKgyBcenND0kd/+6ukHlHnSVvBtNcce4GV/kR6eet+muiveIJLciqg yrkv/6GipLRCeYh8Ki6NJTLFlE1B2s6jpC2QmyAUOCczZZ24zHJz9taqTLSD0RMX0TmM I92I4of4wY40qTGeT//1ksEHmmLt4nCYjK9Oa+pvmPXJBCml28ySOn8bURI0Pc+mNBrz knlvJfJqDEjZIzZNDHrQea3X1hs//CGFwQECdLgrS/8ilGfAp7rt2pKCILZVkCjYrEgA bDow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694835038; x=1695439838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yHjWbAi9btcVTSvND+C/MROFnqLtNDPhov9ERvl3KYw=; b=DfGXwTBIerNoi4NgCfFskZUr55nNTsyVMxmHJCKVyNPrI3N4k1QxdxTFqhTtL1gRVI oQl5F0LCn1zmBFevmB4gOcclXqU6WyhOoITri1r49ddWGdOfv4zL07Wc70qf1sZjyjdP YDm6YB33vVyvmATBoDYuRobn5D2I08OX0Likb4+Yk+zvRdctje0Fp6chnaX/bQwebleh QiXUCh9UQ+PgYanaJjA3Ek/DnB7wKjILjEIQxX1iTHuBnj0WJrOF4xPoBr2aMdnOEmyS 2l2QMPLeLHLLV3+mgvJsmhORuMcZKOpnXadXD2T3yeXgxEu26yXYiNlmI9R5djbrHoP3 d77A== X-Gm-Message-State: AOJu0Ywst2DtfjlDk3+naYaoCtMAao4r9+eiwx2N9tKRnUHzmOcBILvI TTwDObGjgpwBxjBbjCQyzvaEOMJcy2geyEvDjbM= X-Received: by 2002:a05:6a00:2d83:b0:68a:586a:f62 with SMTP id fb3-20020a056a002d8300b0068a586a0f62mr3679630pfb.4.1694835038048; Fri, 15 Sep 2023 20:30:38 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id j26-20020aa783da000000b00687a4b70d1esm3577320pfn.218.2023.09.15.20.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 20:30:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 27/39] plugin: Simplify struct qemu_plugin_hwaddr Date: Fri, 15 Sep 2023 20:29:59 -0700 Message-Id: <20230916033011.479144-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230916033011.479144-1-richard.henderson@linaro.org> References: <20230916033011.479144-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rather than saving MemoryRegionSection and offset, save phys_addr and MemoryRegion. This matches up much closer with the plugin api. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/qemu/plugin-memory.h | 11 ++--------- accel/tcg/cputlb.c | 16 +++++++++------- plugins/api.c | 27 ++++++--------------------- 3 files changed, 17 insertions(+), 37 deletions(-) diff --git a/include/qemu/plugin-memory.h b/include/qemu/plugin-memory.h index 43165f2452..71c1123308 100644 --- a/include/qemu/plugin-memory.h +++ b/include/qemu/plugin-memory.h @@ -15,15 +15,8 @@ struct qemu_plugin_hwaddr { bool is_io; bool is_store; - union { - struct { - MemoryRegionSection *section; - hwaddr offset; - } io; - struct { - void *hostaddr; - } ram; - } v; + hwaddr phys_addr; + MemoryRegion *mr; }; /** diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index a46be6a120..fd1b07c5a3 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1724,23 +1724,25 @@ bool tlb_plugin_lookup(CPUState *cpu, vaddr addr, int mmu_idx, uintptr_t index = tlb_index(env, mmu_idx, addr); MMUAccessType access_type = is_store ? MMU_DATA_STORE : MMU_DATA_LOAD; uint64_t tlb_addr = tlb_read_idx(tlbe, access_type); + CPUTLBEntryFull *full; if (unlikely(!tlb_hit(tlb_addr, addr))) { return false; } + full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; + data->phys_addr = full->phys_addr | (addr & ~TARGET_PAGE_MASK); + /* We must have an iotlb entry for MMIO */ if (tlb_addr & TLB_MMIO) { - CPUTLBEntryFull *full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; - hwaddr xlat = full->xlat_section; - + MemoryRegionSection *section = + iotlb_to_section(cpu, full->xlat_section & ~TARGET_PAGE_MASK, + full->attrs); data->is_io = true; - data->v.io.offset = (xlat & TARGET_PAGE_MASK) + addr; - data->v.io.section = - iotlb_to_section(cpu, xlat & ~TARGET_PAGE_MASK, full->attrs); + data->mr = section->mr; } else { data->is_io = false; - data->v.ram.hostaddr = (void *)((uintptr_t)addr + tlbe->addend); + data->mr = NULL; } return true; } diff --git a/plugins/api.c b/plugins/api.c index 2078b16edb..5521b0ad36 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -316,22 +316,7 @@ uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr) { #ifdef CONFIG_SOFTMMU if (haddr) { - if (!haddr->is_io) { - RAMBlock *block; - ram_addr_t offset; - void *hostaddr = haddr->v.ram.hostaddr; - - block = qemu_ram_block_from_host(hostaddr, false, &offset); - if (!block) { - error_report("Bad host ram pointer %p", haddr->v.ram.hostaddr); - abort(); - } - - return block->offset + offset + block->mr->addr; - } else { - MemoryRegionSection *mrs = haddr->v.io.section; - return mrs->offset_within_address_space + haddr->v.io.offset; - } + return haddr->phys_addr; } #endif return 0; @@ -341,13 +326,13 @@ const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h) { #ifdef CONFIG_SOFTMMU if (h && h->is_io) { - MemoryRegionSection *mrs = h->v.io.section; - if (!mrs->mr->name) { - unsigned long maddr = 0xffffffff & (uintptr_t) mrs->mr; - g_autofree char *temp = g_strdup_printf("anon%08lx", maddr); + MemoryRegion *mr = h->mr; + if (!mr->name) { + unsigned maddr = (uintptr_t)mr; + g_autofree char *temp = g_strdup_printf("anon%08x", maddr); return g_intern_string(temp); } else { - return g_intern_string(mrs->mr->name); + return g_intern_string(mr->name); } } else { return g_intern_static_string("RAM");