From patchwork Sat Sep 16 03:29:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 723557 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp709059wro; Fri, 15 Sep 2023 20:33:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6uxnntW/kYNiN719HFx2oLqNf6q/wGeqqlsAqCVjX8d39FJVug6KSglm774ittEjjWu/t X-Received: by 2002:a05:620a:4456:b0:76d:921d:52d2 with SMTP id w22-20020a05620a445600b0076d921d52d2mr3929239qkp.10.1694835205469; Fri, 15 Sep 2023 20:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694835205; cv=none; d=google.com; s=arc-20160816; b=A7N8VAUeutXtDt9956DMV6iWA/myViI4JjNsV5nIQhZhli40vw5iMjT0nLkpj4DgKv WMN/JwYTTqbCKPZbM0tcSvf+owgz+J496oP6rr4CGj+flPPeosqSUVR3k55/J57JfuvK 4loDvVt/RSljmrEdok5lPN8tySP2fzm5CxYcmcrftLxqefSwkB56N3dD33oUEu8gHfML wTPtBanWYytzg3OlrFzPmSaBT7oz4ucKB13Q58oEjye5T4+zTSG0quh6EU8ohgvFdKvw +fXuARMq/qA2GUI4sxCHlAvR/fzg6TGFMLyChH/H2bmcPbTwxcr2mwDX2mFv0UpopdyW vk2g== 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=bw6itF1Uknpm4DtF+K1DJWMJ4/HW9rR4t/tDfUwyoM4=; fh=j7Cmyqi3/gQ6PVbMIYTABTAC5JDdWyCAx0HC845o5JA=; b=k/jXvoesuCqRuUJcXqJvxc8Wq5qx5NhpuP0mknuoc79FJ8stvXSSytQ1GhZmLFLI64 ehGNKrqyI8iZNWc0E4B9U5AIFhi15f7Inog2bdqV5kU43OjkNOFJxNSO/ibkrDKXg62y sBR2xVXPfvpe+RJLmQMPjrhvKZ4MNRru7sQ2TG06BAiJCzmZF+54DQoNEidpfRZ1Rhsu jI4Y7ajDUhM/9k9AeVn+s8QkSSq0mM7iWhAozgtnzAHh5B0zMSoZCcXTX5ides/sqQXd gw1lSS2U23B5X+m5p6FD9G416IcTIhwGhx14Ep5Bb3VbK4Yl+v/4zai/qXZaUCJNvxVH 170A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KBCj6LhR; 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 u10-20020a05620a430a00b00770753a5a1fsi3260193qko.757.2023.09.15.20.33.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Sep 2023 20:33:25 -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=KBCj6LhR; 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 1qhM0i-0005sj-EW; Fri, 15 Sep 2023 23:30:20 -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 1qhM0h-0005sI-65 for qemu-devel@nongnu.org; Fri, 15 Sep 2023 23:30:19 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhM0e-0007yP-SZ for qemu-devel@nongnu.org; Fri, 15 Sep 2023 23:30:18 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68fb79ef55eso2598939b3a.0 for ; Fri, 15 Sep 2023 20:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694835015; x=1695439815; 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=bw6itF1Uknpm4DtF+K1DJWMJ4/HW9rR4t/tDfUwyoM4=; b=KBCj6LhRcbO6pDEhtpq82pT/wd8Dfvyns2FwYGvLGonI7/odbGYTgMlIEtjWukrf2c OzARzZw5H5Rmk/XAKPjVtmzt1yDooKDd9TH9xjjwzRx/RsLDDZomUThgALKsc2I8Yt9P cbUEz8xOw1pmdUqNNXZYVxI4nijnO7mXwlIrhZa2PoZ+NssHntNtYWazykzMSNgZ2q91 KVYRJzK9nDmRvJ+FMdSy0VauUH5WvsZCijHjrJKPyW7EibuKW60viLxU8FLu5mOqUWZQ ogrBY0lAqKrcrneHgTKvmZH2YpZJU39xwAzoC+7E1CIdnjBZu3MhtVcjWSN6GDpreIy5 UtnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694835015; x=1695439815; 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=bw6itF1Uknpm4DtF+K1DJWMJ4/HW9rR4t/tDfUwyoM4=; b=cBIs52dqqHkMS6jSGXA2pqbR7A8kcfXCtAHQWohP3E3h/HNBhwTOHnFqfcEhAl1emR Ku+beylIGBfCbEYzsKK/WvvS5dDkMTK9xiR6N6SMy7oSX1JOm76Qc8PBryUyugn5M67f 528D4iE+02AGTLsFizAtoI24zFn8FwMMw4WBNa5eSbzemFfiGu0KpbGbqIExnAxdQas+ Axq7YsWbnR9LcBwVT3yDOdXViYg+HF0J3rn9MeCBuu4QATkl6Tb0KhD4jJYlL1HBFEVx oxhHQNHE5jInkb0oXtZmqKKjawi9a/G0euUj4mz3qUumI5cxDFESU5eAEhBydqUALY6r QsYQ== X-Gm-Message-State: AOJu0YxU4oztfXBi+AJ8DJEo6W5tZ1WRdAq6v98jKfVX4uGiRrivyCa/ ze7iGI0BfsAuMUuExBibUBNXc2tXR6XrC4NyO5Y= X-Received: by 2002:a05:6a00:14c2:b0:690:2ecd:a59e with SMTP id w2-20020a056a0014c200b006902ecda59emr4334081pfu.31.1694835015343; Fri, 15 Sep 2023 20:30:15 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id j26-20020aa783da000000b00687a4b70d1esm3577320pfn.218.2023.09.15.20.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 20:30:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: LIU Zhiwei Subject: [PULL 02/39] accel/tcg: Fix the comment for CPUTLBEntryFull Date: Fri, 15 Sep 2023 20:29:34 -0700 Message-Id: <20230916033011.479144-3-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: LIU Zhiwei When memory region is ram, the lower TARGET_PAGE_BITS is not the physical section number. Instead, its value is always 0. Add comment and assert to make it clear. Signed-off-by: LIU Zhiwei Message-Id: <20230901060118.379-1-zhiwei_liu@linux.alibaba.com> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- include/exec/cpu-defs.h | 12 ++++++------ accel/tcg/cputlb.c | 11 +++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index fb4c8d480f..350287852e 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -100,12 +100,12 @@ typedef struct CPUTLBEntryFull { /* * @xlat_section contains: - * - in the lower TARGET_PAGE_BITS, a physical section number - * - with the lower TARGET_PAGE_BITS masked off, an offset which - * must be added to the virtual address to obtain: - * + the ram_addr_t of the target RAM (if the physical section - * number is PHYS_SECTION_NOTDIRTY or PHYS_SECTION_ROM) - * + the offset within the target MemoryRegion (otherwise) + * - For ram, an offset which must be added to the virtual address + * to obtain the ram_addr_t of the target RAM + * - For other memory regions, + * + in the lower TARGET_PAGE_BITS, the physical section number + * + with the TARGET_PAGE_BITS masked off, the offset within + * the target MemoryRegion */ hwaddr xlat_section; diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index c643d66190..03e27b2a38 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1193,6 +1193,7 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, write_flags = read_flags; if (is_ram) { iotlb = memory_region_get_ram_addr(section->mr) + xlat; + assert(!(iotlb & ~TARGET_PAGE_MASK)); /* * Computing is_clean is expensive; avoid all that unless * the page is actually writable. @@ -1255,10 +1256,12 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, /* refill the tlb */ /* - * 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 (RAM) - * + the offset within section->mr of the page base (I/O, ROMD) + * When memory region is ram, iotlb contains a TARGET_PAGE_BITS + * aligned ram_addr_t of the page base of the target RAM. + * Otherwise, iotlb contains + * - a physical section number in the lower TARGET_PAGE_BITS + * - the offset within section->mr of the page base (I/O, ROMD) with the + * TARGET_PAGE_BITS masked off. * We subtract addr_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