From nobody Sun Sep 28 16:58:18 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758740849; cv=none; d=zohomail.com; s=zohoarc; b=hrxciUoTXFEYLaBDiCUohwjg05D8vMS9rGNI5/jJlpCUvp3Kts0DDDV9WmdyyjVCbKe4d3M+eL/nhWEwZ+pxnhvyANB5kCqpYOv67MraBhNXclYmEXq6k2hrZD/5UGKIr8X2tVEqumA86x3xnCDVp2K3pWhTJ4kPtPUmSFCVkwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758740849; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZygRgWqMIPynqxmUOZPgP9Z18/5uGvzS6u9rDKliUcs=; b=S3DUyN8/JEE2wo3mDbAm99gRIx4BK5oX82npLvgOqDLpvIFcdQi2RBwkTOCnOH4Fl/9l4T0CO8t5oJpvb65a61ZIFtQgzPEqaizCICNU6UQiHWOoiW8nn5ka72J+mim8KGowgr/wZi2KFlwsC58mSB/jAuMs44DmjEnrpPDUc2c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758740849700978.220931387372; Wed, 24 Sep 2025 12:07:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1UnQ-0007y9-PS; Wed, 24 Sep 2025 15:04:56 -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 1v1Uly-0006wO-DE for qemu-devel@nongnu.org; Wed, 24 Sep 2025 15:03:29 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Uk0-0007rp-8q for qemu-devel@nongnu.org; Wed, 24 Sep 2025 15:03:25 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-33255011eafso165932a91.1 for ; Wed, 24 Sep 2025 12:01:21 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-33439103461sm63221a91.8.2025.09.24.12.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Sep 2025 12:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758740478; x=1759345278; 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=ZygRgWqMIPynqxmUOZPgP9Z18/5uGvzS6u9rDKliUcs=; b=PmJgD8CV60AlD+Iu5AHuWy/NjGF1kNrFb/QI8K2ilywIhFDXDy740g8Ib6otHQySaR 3JDca05BGctri3HIpEJzqLxUFhdjeEGnCMak1TL/rFGS+ZV0XzypzZNWP0fFwdRmdVzl h604r3o4jYDXuIdT4QRsBJfq9JIAis0UrLaC6ylXZC9ZyO1CMfvI66B5ysPuvstoO3fc zi0D3aW5L59o1ZN+xZEHvJiGQZ5dCTekCNwYYrGuTyYZOZQvCSijCaVs2XJVzhdxlA2L k1065w++qBY1MxeLNhlw9R/1OB1R3ryMndsbvNIkGTKbsx4FnN9lfMnxA/w+ZiIblDg4 o4vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758740479; x=1759345279; 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=ZygRgWqMIPynqxmUOZPgP9Z18/5uGvzS6u9rDKliUcs=; b=Lw5isMS11B4GUAJAB4Jk5+/biNdTR8lDPaRdal8OL9qxyIy9JciyXLYdSwCO5/07T9 TkHE3JZQVG2U/pJnK2J1pTu5rdFXwsgY+jp6KrOR9lJaIrD5e5pd2ftetR96UdrIL4FX 6eeC4iHp0c+Pa6mhXX/QfAPiryncz4t8P3nIi4veF89SQlvu4bQ1oydCMHSySn1knjLQ c/U0QQKGby+N2OUEtoFRWSVHj0myUPJNzeqqTZnT9ELNYmCc9riMLYivP3AeearrYKCk WJYPqSr2EATLFDsWKijWbVn6/xeTIN2aUxBdhz/PcEUJlnVyqR/Lq0hln/o6qrIM1Zpv 2KHA== X-Gm-Message-State: AOJu0Yx8MIC/5SexxFTlY0EsB/TCvQ3bqMCw0N+47hL3fH5nPo6DPSHK pGPr+Dvb/dWpD3vicrpXw44kkxXAvO8ws6nXu63XpiZnEosBSLp2prDg3Lxz21no0b8m8remv4U WxhI2 X-Gm-Gg: ASbGncteVZV568z55QqyHV7asfMoH/7eFLcqBVduFiQJs3wlBpyxfdYfNLT4thdbI9R rreVoOf9BKnM7ZNViLq+Qp2ntOnkrvecN7rSPyUF1CtHC7hDBqIheLQJYadoTc4dokdmWklprTi WNiXy0IpaYTaqFxDyJ9QAWQTdvKzBT2Xd9E4POS4P9zVsWXDJTDfpdfLfCvztfE7NS8Ifldj7Yg jVaM47vGrHKh//EN/e99i1gK1IKI7MswlTfEI8P5NATmYO/bHAq8l7plt+xx0EFI/GkTTNUJWQY uTGbce+Wa07NVtScRNR+GsaKp78gGpOcCMyWHYH0AcDO7yLpyXczqv1aMlO+4f+OF9a45SuIm7I IsVsco7pmOJmhxxtsIVsVgb9jG8Us X-Google-Smtp-Source: AGHT+IGJSk6JugIZmf81T8xS6gTEYBr2nYVEv7YfpW2cCRQIWgK5qDaDY51X48hZC1d0wI8V0ybyWg== X-Received: by 2002:a17:90b:164a:b0:330:6f16:c4e0 with SMTP id 98e67ed59e1d1-3342a22ca94mr1000484a91.12.1758740478516; Wed, 24 Sep 2025 12:01:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PULL 15/32] include/hw/core/cpu: Introduce MMUIdxMap Date: Wed, 24 Sep 2025 12:00:48 -0700 Message-ID: <20250924190106.7089-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250924190106.7089-1-richard.henderson@linaro.org> References: <20250924190106.7089-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758740851566116600 Use a typedef instead of uint16_t directly when describing sets of mmu indexes. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/exec/cputlb.h | 32 ++++++++++++++++---------------- include/hw/core/cpu.h | 6 +++--- accel/tcg/cputlb.c | 30 +++++++++++++++--------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h index 03ed7e2165..9bec0e7890 100644 --- a/include/exec/cputlb.h +++ b/include/exec/cputlb.h @@ -150,7 +150,7 @@ void tlb_flush_all_cpus_synced(CPUState *src_cpu); * MMU indexes. */ void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, - uint16_t idxmap); + MMUIdxMap idxmap); =20 /** * tlb_flush_page_by_mmuidx_all_cpus_synced: @@ -165,7 +165,7 @@ void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, * translations using the flushed TLBs. */ void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, - uint16_t idxmap); + MMUIdxMap idxmap); =20 /** * tlb_flush_by_mmuidx: @@ -176,7 +176,7 @@ void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState = *cpu, vaddr addr, * Flush all entries from the TLB of the specified CPU, for the specified * MMU indexes. */ -void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap); +void tlb_flush_by_mmuidx(CPUState *cpu, MMUIdxMap idxmap); =20 /** * tlb_flush_by_mmuidx_all_cpus_synced: @@ -189,7 +189,7 @@ void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap= ); * When this function returns, no CPUs will subsequently perform * translations using the flushed TLBs. */ -void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap); +void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, MMUIdxMap idxmap); =20 /** * tlb_flush_page_bits_by_mmuidx @@ -201,11 +201,11 @@ void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cp= u, uint16_t idxmap); * Similar to tlb_flush_page_mask, but with a bitmap of indexes. */ void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, - uint16_t idxmap, unsigned bits); + MMUIdxMap idxmap, unsigned bits); =20 /* Similarly, with broadcast and syncing. */ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr ad= dr, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits); =20 /** @@ -220,14 +220,14 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CP= UState *cpu, vaddr addr, * comparing only the low @bits worth of each virtual page. */ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, - vaddr len, uint16_t idxmap, + vaddr len, MMUIdxMap idxmap, unsigned bits); =20 /* Similarly, with broadcast and syncing. */ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, vaddr len, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits); #else static inline void tlb_flush_page(CPUState *cpu, vaddr addr) @@ -243,42 +243,42 @@ static inline void tlb_flush_all_cpus_synced(CPUState= *src_cpu) { } static inline void tlb_flush_page_by_mmuidx(CPUState *cpu, - vaddr addr, uint16_t idxmap) + vaddr addr, MMUIdxMap idxmap) { } =20 -static inline void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) +static inline void tlb_flush_by_mmuidx(CPUState *cpu, MMUIdxMap idxmap) { } static inline void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, - uint16_t idxma= p) + MMUIdxMap idxm= ap) { } static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, - uint16_t idxmap) + MMUIdxMap idxmap) { } static inline void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits) { } static inline void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, - uint16_t idxmap, unsigned bi= ts) + MMUIdxMap idxmap, unsigned b= its) { } static inline void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, - vaddr len, uint16_t idxmap, + vaddr len, MMUIdxMap idxmap, unsigned bits) { } static inline void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, vaddr len, - uint16_t idxm= ap, + MMUIdxMap idx= map, unsigned bits) { } diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fb788ca110..8dd83f7457 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -198,10 +198,10 @@ struct CPUClass { }; =20 /* - * Fix the number of mmu modes to 16, which is also the maximum - * supported by the softmmu tlb api. + * Fix the number of mmu modes to 16. */ #define NB_MMU_MODES 16 +typedef uint16_t MMUIdxMap; =20 /* Use a fully associative victim tlb of 8 entries. */ #define CPU_VTLB_SIZE 8 @@ -306,7 +306,7 @@ typedef struct CPUTLBCommon { * mmu_idx N since the last time that mmu_idx was flushed. * Protected by tlb_c.lock. */ - uint16_t dirty; + MMUIdxMap dirty; /* * Statistics. These are not lock protected, but are read and * written atomically. This allows the monitor to print a snapshot diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 87e14bde4f..d324f33339 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -370,8 +370,8 @@ static void flush_all_helper(CPUState *src, run_on_cpu_= func fn, =20 static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, run_on_cpu_data = data) { - uint16_t asked =3D data.host_int; - uint16_t all_dirty, work, to_clean; + MMUIdxMap asked =3D data.host_int; + MMUIdxMap all_dirty, work, to_clean; int64_t now =3D get_clock_realtime(); =20 assert_cpu_is_self(cpu); @@ -408,7 +408,7 @@ static void tlb_flush_by_mmuidx_async_work(CPUState *cp= u, run_on_cpu_data data) } } =20 -void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) +void tlb_flush_by_mmuidx(CPUState *cpu, MMUIdxMap idxmap) { tlb_debug("mmu_idx: 0x%" PRIx16 "\n", idxmap); =20 @@ -422,7 +422,7 @@ void tlb_flush(CPUState *cpu) tlb_flush_by_mmuidx(cpu, ALL_MMUIDX_BITS); } =20 -void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *src_cpu, uint16_t idxma= p) +void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *src_cpu, MMUIdxMap idxm= ap) { const run_on_cpu_func fn =3D tlb_flush_by_mmuidx_async_work; =20 @@ -531,7 +531,7 @@ static void tlb_flush_page_locked(CPUState *cpu, int mi= dx, vaddr page) */ static void tlb_flush_page_by_mmuidx_async_0(CPUState *cpu, vaddr addr, - uint16_t idxmap) + MMUIdxMap idxmap) { int mmu_idx; =20 @@ -570,14 +570,14 @@ static void tlb_flush_page_by_mmuidx_async_1(CPUState= *cpu, { vaddr addr_and_idxmap =3D data.target_ptr; vaddr addr =3D addr_and_idxmap & TARGET_PAGE_MASK; - uint16_t idxmap =3D addr_and_idxmap & ~TARGET_PAGE_MASK; + MMUIdxMap idxmap =3D addr_and_idxmap & ~TARGET_PAGE_MASK; =20 tlb_flush_page_by_mmuidx_async_0(cpu, addr, idxmap); } =20 typedef struct { vaddr addr; - uint16_t idxmap; + MMUIdxMap idxmap; } TLBFlushPageByMMUIdxData; =20 /** @@ -599,7 +599,7 @@ static void tlb_flush_page_by_mmuidx_async_2(CPUState *= cpu, g_free(d); } =20 -void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, uint16_t idxmap) +void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, MMUIdxMap idxmap) { tlb_debug("addr: %016" VADDR_PRIx " mmu_idx:%" PRIx16 "\n", addr, idxm= ap); =20 @@ -618,7 +618,7 @@ void tlb_flush_page(CPUState *cpu, vaddr addr) =20 void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *src_cpu, vaddr addr, - uint16_t idxmap) + MMUIdxMap idxmap) { tlb_debug("addr: %016" VADDR_PRIx " mmu_idx:%"PRIx16"\n", addr, idxmap= ); =20 @@ -715,8 +715,8 @@ static void tlb_flush_range_locked(CPUState *cpu, int m= idx, typedef struct { vaddr addr; vaddr len; - uint16_t idxmap; - uint16_t bits; + MMUIdxMap idxmap; + unsigned bits; } TLBFlushRangeData; =20 static void tlb_flush_range_by_mmuidx_async_0(CPUState *cpu, @@ -766,7 +766,7 @@ static void tlb_flush_range_by_mmuidx_async_1(CPUState = *cpu, } =20 void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, - vaddr len, uint16_t idxmap, + vaddr len, MMUIdxMap idxmap, unsigned bits) { TLBFlushRangeData d; @@ -797,7 +797,7 @@ void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr add= r, } =20 void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, - uint16_t idxmap, unsigned bits) + MMUIdxMap idxmap, unsigned bits) { tlb_flush_range_by_mmuidx(cpu, addr, TARGET_PAGE_SIZE, idxmap, bits); } @@ -805,7 +805,7 @@ void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr= addr, void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *src_cpu, vaddr addr, vaddr len, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits) { TLBFlushRangeData d, *p; @@ -847,7 +847,7 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState= *src_cpu, =20 void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu, vaddr addr, - uint16_t idxmap, + MMUIdxMap idxmap, unsigned bits) { tlb_flush_range_by_mmuidx_all_cpus_synced(src_cpu, addr, TARGET_PAGE_S= IZE, --=20 2.43.0