From nobody Tue May 14 10:11:32 2024 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=1677185115; cv=none; d=zohomail.com; s=zohoarc; b=TuQxlhoFcLJxbcEcwwHTUF3dkJQnB0Wk8SeYt6sFwK0SBGfxZrfaNekePV6yNpeLvHyUVAUg2M29bXixQhxhwqjLBTMr8vnCtz9+Wa/JWUkqaEQCKcTACltGezVHiiqwuXcIFT/Gr83sFU4/GRKVWYoR+cQ+L/KSDhDzBzdx1mA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185115; h=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; bh=N9ofc0CdkfvI0sj5X3EW+klo2rQGa2mDhM3KZBvNWdU=; b=BHuieMb6orwpEaPZcNajn+V8B/mPyxz2lcrAb8/ek0IOMLuOjH0ce1r/sWyuwEDbCQhYGCyMitSUh7O8HgdYtrCDcQNsQjMHZakuHUnOCnEnKV5iRPiMETJI4PW8XNSReeXuvXSSOLmU8vhX6w8DVHWIeBtvAABTYslfmoxZLBw= 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 1677185115479932.3642345306747; Thu, 23 Feb 2023 12:45:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRW-0002lX-UW; Thu, 23 Feb 2023 15:43:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRV-0002j3-0S for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:53 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRS-0007Pi-SN for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:52 -0500 Received: by mail-pj1-x1034.google.com with SMTP id qi12-20020a17090b274c00b002341621377cso594126pjb.2 for ; Thu, 23 Feb 2023 12:43:50 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:43:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N9ofc0CdkfvI0sj5X3EW+klo2rQGa2mDhM3KZBvNWdU=; b=XREkinomMTHs6e/RJS+hFiMGgHgCOY6P8r/0KdxfluDzmmjrIn2HavVQWuPvA6dTCR JLMbr28+LDdZXfnZQHo2TNPcs7JEeHxU1loMf31d9OzJ2TDtRSPVppWx9j85VXViEAQd s9jbsTAY3n+wyYlodeYYiIqy/piwWCZP508evi4RGOQeQeO5R4nABiDL3iuYO+L+LRoX 1mM5mXIjtZ6FwDgdplFyXCxC7A76rFQQc/gwhLvcNwh0zWux1bkav7sMBDHRC3EHuijB 2qGWi4BYQiYITKwxMsj2Rd0Pd6i2e6uh3/vfZSk9Qk2EdgqfpRqwzdF9QbCdW9hvh3T/ 9gEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N9ofc0CdkfvI0sj5X3EW+klo2rQGa2mDhM3KZBvNWdU=; b=r8lJ1U10hoqFijFe7AR6j8dxcrCXjtQbeIH23Qh7EBDuBhndlAxnleWMJPhqMxD9ov FARJxI02BHjvUTsrD8dj3hmXT7ugJNNQcGPyKcs+ksTzng1KyWxddrgRE4x9WO5Bfife /wFGBKNG4Mv5+OUfS8viZqIPG6ep+FCijbOvpm1tqVy3a49zuMxIC/xKbulZVy9xInm0 UTt9huJqrZR+v188C+Ny3Ch01qhdcumbfOw0diFUzeFPr0rrn2YdcTjSSwiScWRe+nTi 6M4N8XCbd9a8OwIQ+lpt1jc6iQd77oO0KCcZXzYKbqP1a71omtCsSQ0A23tNXz+GpaQd NpeA== X-Gm-Message-State: AO0yUKUnznWyqnTZUpX4W17u953q157a05a0STWxmajEcSRDOSJKYNgC bS0cQUbOF/oBhIeiULw9vUlOG10T56UrEcv2Dq8= X-Google-Smtp-Source: AK7set8vy3cvHeo/xltwXsCVEJwMwvX0NoDiQGmoZ6lWiGId8C+Ona66epA4MdqoRD2VJ8gyc0DobA== X-Received: by 2002:a05:6a20:12d0:b0:cb:9afd:8ad0 with SMTP id v16-20020a056a2012d000b000cb9afd8ad0mr11952950pzg.19.1677185029392; Thu, 23 Feb 2023 12:43:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Mark Cave-Ayland , Artyom Tarasenko Subject: [PATCH 01/13] target/sparc: Use tlb_set_page_full Date: Thu, 23 Feb 2023 10:43:30 -1000 Message-Id: <20230223204342.1093632-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185116874100002 Content-Type: text/plain; charset="utf-8" Pass CPUTLBEntryFull to get_physical_address instead of a collection of pointers. Signed-off-by: Richard Henderson Acked-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Cc: Mark Cave-Ayland Cc: Artyom Tarasenko --- target/sparc/mmu_helper.c | 121 +++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 67 deletions(-) diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index 158ec2ae8f..a98dd0abd4 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -64,10 +64,9 @@ static const int perm_table[2][8] =3D { } }; =20 -static int get_physical_address(CPUSPARCState *env, hwaddr *physical, - int *prot, int *access_index, MemTxAttrs *= attrs, - target_ulong address, int rw, int mmu_idx, - target_ulong *page_size) +static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full, + int *access_index, target_ulong address, + int rw, int mmu_idx) { int access_perms =3D 0; hwaddr pde_ptr; @@ -80,20 +79,20 @@ static int get_physical_address(CPUSPARCState *env, hwa= ddr *physical, is_user =3D mmu_idx =3D=3D MMU_USER_IDX; =20 if (mmu_idx =3D=3D MMU_PHYS_IDX) { - *page_size =3D TARGET_PAGE_SIZE; + full->lg_page_size =3D TARGET_PAGE_BITS; /* Boot mode: instruction fetches are taken from PROM */ if (rw =3D=3D 2 && (env->mmuregs[0] & env->def.mmu_bm)) { - *physical =3D env->prom_addr | (address & 0x7ffffULL); - *prot =3D PAGE_READ | PAGE_EXEC; + full->phys_addr =3D env->prom_addr | (address & 0x7ffffULL); + full->prot =3D PAGE_READ | PAGE_EXEC; return 0; } - *physical =3D address; - *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; + full->phys_addr =3D address; + full->prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return 0; } =20 *access_index =3D ((rw & 1) << 2) | (rw & 2) | (is_user ? 0 : 1); - *physical =3D 0xffffffffffff0000ULL; + full->phys_addr =3D 0xffffffffffff0000ULL; =20 /* SPARC reference MMU table walk: Context table->L1->L2->PTE */ /* Context base + context number */ @@ -157,16 +156,17 @@ static int get_physical_address(CPUSPARCState *env, h= waddr *physical, case 2: /* L3 PTE */ page_offset =3D 0; } - *page_size =3D TARGET_PAGE_SIZE; + full->lg_page_size =3D TARGET_PAGE_BITS; break; case 2: /* L2 PTE */ page_offset =3D address & 0x3f000; - *page_size =3D 0x40000; + full->lg_page_size =3D 18; } break; case 2: /* L1 PTE */ page_offset =3D address & 0xfff000; - *page_size =3D 0x1000000; + full->lg_page_size =3D 24; + break; } } =20 @@ -188,16 +188,16 @@ static int get_physical_address(CPUSPARCState *env, h= waddr *physical, } =20 /* the page can be put in the TLB */ - *prot =3D perm_table[is_user][access_perms]; + full->prot =3D perm_table[is_user][access_perms]; if (!(pde & PG_MODIFIED_MASK)) { /* only set write access if already dirty... otherwise wait for dirty access */ - *prot &=3D ~PAGE_WRITE; + full->prot &=3D ~PAGE_WRITE; } =20 /* Even if large ptes, we map only one 4KB page in the cache to avoid filling it too fast */ - *physical =3D ((hwaddr)(pde & PTE_ADDR_MASK) << 4) + page_offset; + full->phys_addr =3D ((hwaddr)(pde & PTE_ADDR_MASK) << 4) + page_offset; return error_code; } =20 @@ -208,11 +208,9 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, i= nt size, { SPARCCPU *cpu =3D SPARC_CPU(cs); CPUSPARCState *env =3D &cpu->env; - hwaddr paddr; + CPUTLBEntryFull full =3D {}; target_ulong vaddr; - target_ulong page_size; - int error_code =3D 0, prot, access_index; - MemTxAttrs attrs =3D {}; + int error_code =3D 0, access_index; =20 /* * TODO: If we ever need tlb_vaddr_to_host for this target, @@ -223,16 +221,15 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, = int size, assert(!probe); =20 address &=3D TARGET_PAGE_MASK; - error_code =3D get_physical_address(env, &paddr, &prot, &access_index,= &attrs, - address, access_type, - mmu_idx, &page_size); + error_code =3D get_physical_address(env, &full, &access_index, + address, access_type, mmu_idx); vaddr =3D address; if (likely(error_code =3D=3D 0)) { qemu_log_mask(CPU_LOG_MMU, "Translate at %" VADDR_PRIx " -> " HWADDR_FMT_plx ", vaddr " TARGET_FMT_lx "\n", - address, paddr, vaddr); - tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size); + address, full.phys_addr, vaddr); + tlb_set_page_full(cs, mmu_idx, vaddr, &full); return true; } =20 @@ -247,8 +244,8 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, in= t size, permissions. If no mapping is available, redirect accesses to neverland. Fake/overridden mappings will be flushed when switching to normal mode. */ - prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; - tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, TARGET_PAGE_SIZE); + full.prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; + tlb_set_page_full(cs, mmu_idx, vaddr, &full); return true; } else { if (access_type =3D=3D MMU_INST_FETCH) { @@ -545,8 +542,7 @@ static uint64_t build_sfsr(CPUSPARCState *env, int mmu_= idx, int rw) return sfsr; } =20 -static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, - int *prot, MemTxAttrs *attrs, +static int get_physical_address_data(CPUSPARCState *env, CPUTLBEntryFull *= full, target_ulong address, int rw, int mmu= _idx) { CPUState *cs =3D env_cpu(env); @@ -579,11 +575,12 @@ static int get_physical_address_data(CPUSPARCState *e= nv, hwaddr *physical, =20 for (i =3D 0; i < 64; i++) { /* ctx match, vaddr match, valid? */ - if (ultrasparc_tag_match(&env->dtlb[i], address, context, physical= )) { + if (ultrasparc_tag_match(&env->dtlb[i], address, context, + &full->phys_addr)) { int do_fault =3D 0; =20 if (TTE_IS_IE(env->dtlb[i].tte)) { - attrs->byte_swap =3D true; + full->attrs.byte_swap =3D true; } =20 /* access ok? */ @@ -616,9 +613,9 @@ static int get_physical_address_data(CPUSPARCState *env= , hwaddr *physical, } =20 if (!do_fault) { - *prot =3D PAGE_READ; + full->prot =3D PAGE_READ; if (TTE_IS_W_OK(env->dtlb[i].tte)) { - *prot |=3D PAGE_WRITE; + full->prot |=3D PAGE_WRITE; } =20 TTE_SET_USED(env->dtlb[i].tte); @@ -645,8 +642,7 @@ static int get_physical_address_data(CPUSPARCState *env= , hwaddr *physical, return 1; } =20 -static int get_physical_address_code(CPUSPARCState *env, hwaddr *physical, - int *prot, MemTxAttrs *attrs, +static int get_physical_address_code(CPUSPARCState *env, CPUTLBEntryFull *= full, target_ulong address, int mmu_idx) { CPUState *cs =3D env_cpu(env); @@ -681,7 +677,7 @@ static int get_physical_address_code(CPUSPARCState *env= , hwaddr *physical, for (i =3D 0; i < 64; i++) { /* ctx match, vaddr match, valid? */ if (ultrasparc_tag_match(&env->itlb[i], - address, context, physical)) { + address, context, &full->phys_addr)) { /* access ok? */ if (TTE_IS_PRIV(env->itlb[i].tte) && is_user) { /* Fault status register */ @@ -708,7 +704,7 @@ static int get_physical_address_code(CPUSPARCState *env= , hwaddr *physical, =20 return 1; } - *prot =3D PAGE_EXEC; + full->prot =3D PAGE_EXEC; TTE_SET_USED(env->itlb[i].tte); return 0; } @@ -722,14 +718,13 @@ static int get_physical_address_code(CPUSPARCState *e= nv, hwaddr *physical, return 1; } =20 -static int get_physical_address(CPUSPARCState *env, hwaddr *physical, - int *prot, int *access_index, MemTxAttrs *= attrs, - target_ulong address, int rw, int mmu_idx, - target_ulong *page_size) +static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full, + int *access_index, target_ulong address, + int rw, int mmu_idx) { /* ??? We treat everything as a small page, then explicitly flush everything when an entry is evicted. */ - *page_size =3D TARGET_PAGE_SIZE; + full->lg_page_size =3D TARGET_PAGE_BITS; =20 /* safety net to catch wrong softmmu index use from dynamic code */ if (env->tl > 0 && mmu_idx !=3D MMU_NUCLEUS_IDX) { @@ -747,17 +742,15 @@ static int get_physical_address(CPUSPARCState *env, h= waddr *physical, } =20 if (mmu_idx =3D=3D MMU_PHYS_IDX) { - *physical =3D ultrasparc_truncate_physical(address); - *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; + full->phys_addr =3D ultrasparc_truncate_physical(address); + full->prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return 0; } =20 if (rw =3D=3D 2) { - return get_physical_address_code(env, physical, prot, attrs, addre= ss, - mmu_idx); + return get_physical_address_code(env, full, address, mmu_idx); } else { - return get_physical_address_data(env, physical, prot, attrs, addre= ss, - rw, mmu_idx); + return get_physical_address_data(env, full, address, rw, mmu_idx); } } =20 @@ -768,25 +761,17 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, = int size, { SPARCCPU *cpu =3D SPARC_CPU(cs); CPUSPARCState *env =3D &cpu->env; - target_ulong vaddr; - hwaddr paddr; - target_ulong page_size; - MemTxAttrs attrs =3D {}; - int error_code =3D 0, prot, access_index; + CPUTLBEntryFull full =3D {}; + int error_code =3D 0, access_index; =20 address &=3D TARGET_PAGE_MASK; - error_code =3D get_physical_address(env, &paddr, &prot, &access_index,= &attrs, - address, access_type, - mmu_idx, &page_size); + error_code =3D get_physical_address(env, &full, &access_index, + address, access_type, mmu_idx); if (likely(error_code =3D=3D 0)) { - vaddr =3D address; - - trace_mmu_helper_mmu_fault(address, paddr, mmu_idx, env->tl, + trace_mmu_helper_mmu_fault(address, full.phys_addr, mmu_idx, env->= tl, env->dmmu.mmu_primary_context, env->dmmu.mmu_secondary_context); - - tlb_set_page_with_attrs(cs, vaddr, paddr, attrs, prot, mmu_idx, - page_size); + tlb_set_page_full(cs, mmu_idx, address, &full); return true; } if (probe) { @@ -888,12 +873,14 @@ void dump_mmu(CPUSPARCState *env) static int cpu_sparc_get_phys_page(CPUSPARCState *env, hwaddr *phys, target_ulong addr, int rw, int mmu_idx) { - target_ulong page_size; - int prot, access_index; - MemTxAttrs attrs =3D {}; + CPUTLBEntryFull full =3D {}; + int access_index, ret; =20 - return get_physical_address(env, phys, &prot, &access_index, &attrs, a= ddr, - rw, mmu_idx, &page_size); + ret =3D get_physical_address(env, &full, &access_index, addr, rw, mmu_= idx); + if (ret =3D=3D 0) { + *phys =3D full.phys_addr; + } + return ret; } =20 #if defined(TARGET_SPARC64) --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185225; cv=none; d=zohomail.com; s=zohoarc; b=ZD9WT3mWIP0eY/KDCGp7MspJzGt5NBHwcsb5pfXqXKi1NAGcVE7gB8MPNCLlRlvu4INFnNTXASEUnpZCQ3XE8JlqUr+H6MSkIJPPP6SfAM99hsbJ3mmAU5K5/77LoBEcsizGDBbuh4Rh05o/itaSswZqzfEknfZOwstD882frt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185225; h=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; bh=m3uf45aNqmoWHA7BxhgBMDgfKLKR3Hs0LkS31+eiMNU=; b=mz7TT7E6rLxr6laNQURuqwhjsEBr8Q7sVaOS9W3haHaJ7NcDGqlgM1Q7xdidWgdR6RuDrki7ziTU7ExYVIXIEB9epCeEkxIBYJaMT5APphTZN5G4gRCLe8QZPb7cgT627iijtinFE4NmkfS3uPV/VYY8St+dPFSii5TbeCOljl8= 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 1677185225751771.8944554709583; Thu, 23 Feb 2023 12:47:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRZ-0002mb-1r; Thu, 23 Feb 2023 15:43:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRW-0002jQ-3c for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:54 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRU-0007QA-5p for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:53 -0500 Received: by mail-pl1-x62f.google.com with SMTP id q11so14829499plx.5 for ; Thu, 23 Feb 2023 12:43:51 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m3uf45aNqmoWHA7BxhgBMDgfKLKR3Hs0LkS31+eiMNU=; b=xFJK81G6y60hJSq+g8lrIzMMCS7am57ThhfMsuBVMvAc+Uj6Kxtm4tCFRuUuUjDERe c2Iv0MPCjRwdmDVbLC478W66+5Rvfkk/7aMJPgR1/kS9r5te6C/gk6secIGq3LyRafEi 0RFXVvoBOA+gP0vyUBBTpzDPo8zVNtfaLndtGQkEC2JQewtBIbCyHXMNxGgh7GZRwLS3 EznFxW9etI6IHHBRHrhqnPbZwcHpiOZutDNiztajwj6VEkYT2JYC9r1q/In/sLJCSKtO ePTjGvgUPz9C3OL1eNeOpJ9jpN5JEJZhQh5x+OvED4qN49i+GaUt+PZ/DoQApggKucVp kiIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m3uf45aNqmoWHA7BxhgBMDgfKLKR3Hs0LkS31+eiMNU=; b=Vbv+ez2OgIIPWNz9X4rBRqhAXEl15WMhxy7N0PJRAodgo1yybKUc1x1F6By9C2rQUG ZKE8QRPUtMZoQGgRZEQcArmq1OgfIAgDo/k/NKCDsu8pMPmo/eSsUk4aS7Fg5GmT/mK2 Wyg0SzVxy3WSypw1tc9MYtksbx2nHzurP6I2roi3oNvQCQHjiNkHgHTM834cw6RFcnM5 WfnvCOGfl+U9fB8trKTamIIxAjICmhKhQHlXuxHE0KcXFEMA5NTxXtjJqYcWxxoTYd+L qb3jHhSiRDxUuv9uFFvIrypKwcuzF6eLaZymTOaiy6poIUcr9IL1x6I+230z6Gwq8bTp Y3Qg== X-Gm-Message-State: AO0yUKXha5Fij6yidwMiIwQGzowyFe6D6R3Bi0Vou4cGQFhDJSTwEXv9 oCM7Z9nBN2xVKGnKkSw9C1JPZM5Vuh5Cg0pD+b4= X-Google-Smtp-Source: AK7set+YwK7LQmSdzXvndRhdhCrKpvuF2ZQEdfyTjtDgvJQa13jXkO/97Xe3hXpDm2XlXbtvD9VzYw== X-Received: by 2002:a05:6a20:690d:b0:cb:c266:3f6b with SMTP id q13-20020a056a20690d00b000cbc2663f6bmr8770526pzj.12.1677185030839; Thu, 23 Feb 2023 12:43:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 02/13] accel/tcg: Retain prot flags from tlb_fill Date: Thu, 23 Feb 2023 10:43:31 -1000 Message-Id: <20230223204342.1093632-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185227385100001 Content-Type: text/plain; charset="utf-8" While changes are made to prot within tlb_set_page_full, they are an implementation detail of softmmu. Retain the original for any target use of probe_access_full. Fixes: 4047368938f6 ("accel/tcg: Introduce tlb_set_page_full") Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- accel/tcg/cputlb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index d7ca90e3b4..169adc0262 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1251,7 +1251,6 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, desc->fulltlb[index] =3D *full; desc->fulltlb[index].xlat_section =3D iotlb - vaddr_page; desc->fulltlb[index].phys_addr =3D paddr_page; - desc->fulltlb[index].prot =3D prot; =20 /* Now calculate the new entry */ tn.addend =3D addend - vaddr_page; --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185200; cv=none; d=zohomail.com; s=zohoarc; b=L34gWs/eqAIKvlmovJOAchj23JcFuqm3dwkxZz4Q2UbnZUUcOJAJ8tERNkzb+IvgW1W3m0S0nQQl+heSNgA8IMczdLHfVhtDik5BwKYCP4XsWjL5PAe/Kx/bLZcpbqiByLmGZsEf9g07fgzJ3Z6jMPavdhgcseGo/nwc5j1cz10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185200; h=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; bh=z2QI1lNn/XT+gr65A4/6/WrKy8DpP4zP5U+ng+Laukk=; b=h8aSiLmiSu5ibpkfAH5slgabLB4xGtorLR2XxU+lBL+NHJJxPddGlI1jiNc2+WpuxZhgIVCtb67DUoTYhz/ThK35/R+c4EGPMzheE8t+w0ZFrVptTma17QEW8k/v/QQNuWVKvW6XhIkftPrTgsbSMgzxc5QgOM3ctMQ2HsIVfZQ= 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 167718520022798.64836678022186; Thu, 23 Feb 2023 12:46:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRZ-0002n2-Q7; Thu, 23 Feb 2023 15:43:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRY-0002m1-2w for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:56 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRW-0007QW-0c for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:55 -0500 Received: by mail-pl1-x633.google.com with SMTP id q11so14829581plx.5 for ; Thu, 23 Feb 2023 12:43:53 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:43:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z2QI1lNn/XT+gr65A4/6/WrKy8DpP4zP5U+ng+Laukk=; b=Ir61O+kRlzD86S9OzSOcNrV234gkeqaFPvClRj8oAU8mVuJ15pOwSKp9TQIEl+e03f H6Zz+RX79irxVD/EQhgHMwPyEXvy1/Q5va/GVktGRgSBP2b/4bY6iGPGuOaWVTYVKl6O OGag/vsgIowzzKvOc1JjpuiFVft2JUlV2IIDtfsbWjKNsAfn/vZouW5fUyD2sHQhYc2L Y28+myKM8KzxkWKLogfBopGzH89KmxUZxCRcS5Ss0vce2Tb6TqtnmykrOEwS0VLJREH4 TgK4mpDVhbJYRzt1gms72VAgQjBUrL5gjWloKBnS0rlhlwE4q+ywrqkI+HbsFL2vt2ze zDzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z2QI1lNn/XT+gr65A4/6/WrKy8DpP4zP5U+ng+Laukk=; b=eehiSZhxdjbTIq4kP3xgLqgxOq2UvbgsRCyJE2uMYnBniUaA943sYMab6Gtc6Csjlh 0K8BBcAWC41Ap+jQZb54jOCpIM6E+TdYhTqM57CdAMR5GjemJilMyKsMlIZ/UZDY4zUN l1KtOYFDWajPA/bQZJILjTkIZP9DvGR10gX5BVMgFpHHBvk8eE1LoT5K0ZQNQ79Lz1Lr iRaJsxQnSmmCOZ6+NTUuXhpWWpY0qlLCwwHMcZnMDrsXbW8a0GpWmdRR1+udUY1aVaTm uL8pEsXZlT4DjAtBcJmJT9fGMkkCvcB3vDp4HFRwDrwVGQ6LPzqNeQa2Ojw5udC57wfJ 1pZw== X-Gm-Message-State: AO0yUKVLE8nDiNqUL7aRVdKND9qAqB2mHLWJ/qVHjfv9GtM+TzjpvSP1 9xg36FQTJ1yOirBVB/ggBgfctS0mmca2DEzx7ww= X-Google-Smtp-Source: AK7set/QF5I9sB5ic67t8WOmIMP54WTifLb4BPeDscQYSN1/jGu/n0CZR1ZePKdfkWwx48+xjM3UWA== X-Received: by 2002:a05:6a20:6926:b0:cb:85eb:611c with SMTP id q38-20020a056a20692600b000cb85eb611cmr13174475pzj.29.1677185032531; Thu, 23 Feb 2023 12:43:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 03/13] accel/tcg: Store some tlb flags in CPUTLBEntryFull Date: Thu, 23 Feb 2023 10:43:32 -1000 Message-Id: <20230223204342.1093632-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185201295100003 Content-Type: text/plain; charset="utf-8" We have run out of bits we can use within the CPUTLBEntry comparators, as TLB_FLAGS_MASK cannot overlap alignment. Store slow_flags[] in CPUTLBEntryFull, and merge with the flags from the comparator. A new TLB_FORCE_SLOW bit is set within the comparator as an indication that the slow path must be used. Move TLB_BSWAP to TLB_SLOW_FLAGS_MASK. Since we are out of bits, we cannot create a new bit without moving an old one. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 21 ++++++++-- include/exec/cpu-defs.h | 6 +++ accel/tcg/cputlb.c | 93 ++++++++++++++++++++++++----------------- 3 files changed, 77 insertions(+), 43 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 2eb1176538..080cb3112e 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -380,17 +380,30 @@ 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)) +/* Set if the slow path must be used; more flags in CPUTLBEntryFull. */ +#define TLB_FORCE_SLOW (1 << (TARGET_PAGE_BITS_MIN - 5)) /* Set if TLB entry writes ignored. */ #define TLB_DISCARD_WRITE (1 << (TARGET_PAGE_BITS_MIN - 6)) =20 -/* Use this mask to check interception with an alignment mask +/* + * 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_BSWAP | TLB_DISCARD_WRITE) + | TLB_WATCHPOINT | TLB_FORCE_SLOW | TLB_DISCARD_WRITE) + +/* + * Flags stored in CPUTLBEntryFull.slow_flags[x]. + * TLB_FORCE_SLOW must be set in CPUTLBEntry.addr_idx[x]. + */ +/* Set if TLB entry requires byte swap. */ +#define TLB_BSWAP (1 << 0) + +#define TLB_SLOW_FLAGS_MASK TLB_BSWAP + +/* The two sets of flags must not overlap. */ +QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & TLB_SLOW_FLAGS_MASK); =20 /** * tlb_hit_page: return true if page aligned @addr is a hit against the diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 7ce3bcb06b..ef10c625d4 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -170,6 +170,12 @@ typedef struct CPUTLBEntryFull { /* @lg_page_size contains the log2 of the page size. */ uint8_t lg_page_size; =20 + /* + * Additional tlb flags for use by the slow path. If non-zero, + * the corresponding CPUTLBEntry comparator must have TLB_FORCE_SLOW. + */ + uint8_t slow_flags[3]; + /* * Allow target-specific additions to this structure. * This may be used to cache items from the guest cpu diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 169adc0262..e9848b3ab6 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1106,6 +1106,24 @@ static void tlb_add_large_page(CPUArchState *env, in= t mmu_idx, env_tlb(env)->d[mmu_idx].large_page_mask =3D lp_mask; } =20 +static inline void tlb_set_compare(CPUTLBEntryFull *full, CPUTLBEntry *ent, + target_ulong address, int flags, + MMUAccessType access_type, bool enable) +{ + if (enable) { + address |=3D flags & TLB_FLAGS_MASK; + flags &=3D TLB_SLOW_FLAGS_MASK; + if (flags) { + address |=3D TLB_FORCE_SLOW; + } + } else { + address =3D -1; + flags =3D 0; + } + ent->addr_idx[access_type] =3D address; + full->slow_flags[access_type] =3D flags; +} + /* * Add a new TLB entry. At most one entry for a given virtual address * is permitted. Only a single TARGET_PAGE_SIZE region is mapped, the @@ -1121,9 +1139,7 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, CPUTLB *tlb =3D env_tlb(env); CPUTLBDesc *desc =3D &tlb->d[mmu_idx]; MemoryRegionSection *section; - unsigned int index; - target_ulong address; - target_ulong write_address; + unsigned int index, read_flags, write_flags; uintptr_t addend; CPUTLBEntry *te, tn; hwaddr iotlb, xlat, sz, paddr_page; @@ -1152,13 +1168,13 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, " prot=3D%x idx=3D%d\n", vaddr, full->phys_addr, prot, mmu_idx); =20 - address =3D vaddr_page; + read_flags =3D 0; if (full->lg_page_size < TARGET_PAGE_BITS) { /* Repeat the MMU check and TLB fill on every access. */ - address |=3D TLB_INVALID_MASK; + read_flags |=3D TLB_INVALID_MASK; } if (full->attrs.byte_swap) { - address |=3D TLB_BSWAP; + read_flags |=3D TLB_BSWAP; } =20 is_ram =3D memory_region_is_ram(section->mr); @@ -1172,7 +1188,7 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, addend =3D 0; } =20 - write_address =3D address; + write_flags =3D read_flags; if (is_ram) { iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; /* @@ -1181,9 +1197,9 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, */ if (prot & PAGE_WRITE) { if (section->readonly) { - write_address |=3D TLB_DISCARD_WRITE; + write_flags |=3D TLB_DISCARD_WRITE; } else if (cpu_physical_memory_is_clean(iotlb)) { - write_address |=3D TLB_NOTDIRTY; + write_flags |=3D TLB_NOTDIRTY; } } } else { @@ -1194,9 +1210,9 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, * 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; + write_flags |=3D TLB_MMIO; if (!is_romd) { - address =3D write_address; + read_flags =3D write_flags; } } =20 @@ -1249,36 +1265,27 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, * vaddr we add back in io_readx()/io_writex()/get_page_addr_code(). */ desc->fulltlb[index] =3D *full; - desc->fulltlb[index].xlat_section =3D iotlb - vaddr_page; - desc->fulltlb[index].phys_addr =3D paddr_page; + full =3D &desc->fulltlb[index]; + full->xlat_section =3D iotlb - vaddr_page; + full->phys_addr =3D paddr_page; =20 /* Now calculate the new entry */ tn.addend =3D addend - vaddr_page; - if (prot & PAGE_READ) { - tn.addr_read =3D address; - if (wp_flags & BP_MEM_READ) { - tn.addr_read |=3D TLB_WATCHPOINT; - } - } else { - tn.addr_read =3D -1; - } =20 - if (prot & PAGE_EXEC) { - tn.addr_code =3D address; - } else { - tn.addr_code =3D -1; - } + tlb_set_compare(full, &tn, vaddr_page, read_flags, + MMU_INST_FETCH, prot & PAGE_EXEC); =20 - tn.addr_write =3D -1; - if (prot & PAGE_WRITE) { - tn.addr_write =3D write_address; - if (prot & PAGE_WRITE_INV) { - tn.addr_write |=3D TLB_INVALID_MASK; - } - if (wp_flags & BP_MEM_WRITE) { - tn.addr_write |=3D TLB_WATCHPOINT; - } + if (wp_flags & BP_MEM_READ) { + read_flags |=3D TLB_WATCHPOINT; } + tlb_set_compare(full, &tn, vaddr_page, read_flags, + MMU_DATA_LOAD, prot & PAGE_READ); + + if (wp_flags & BP_MEM_WRITE) { + write_flags |=3D TLB_WATCHPOINT; + } + tlb_set_compare(full, &tn, vaddr_page, write_flags, MMU_DATA_STORE, + (prot & PAGE_WRITE) && !(prot & PAGE_WRITE_INV)); =20 copy_tlb_helper_locked(te, &tn); tlb_n_used_entries_inc(env, mmu_idx); @@ -1508,7 +1515,8 @@ static int probe_access_internal(CPUArchState *env, t= arget_ulong addr, CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr =3D tlb_read_idx(entry, access_type); target_ulong page_addr =3D addr & TARGET_PAGE_MASK; - int flags =3D TLB_FLAGS_MASK; + int flags =3D TLB_FLAGS_MASK & ~TLB_FORCE_SLOW; + CPUTLBEntryFull *full; =20 if (!tlb_hit_page(tlb_addr, page_addr)) { if (!victim_tlb_hit(env, mmu_idx, index, access_type, page_addr)) { @@ -1537,7 +1545,8 @@ static int probe_access_internal(CPUArchState *env, t= arget_ulong addr, } flags &=3D tlb_addr; =20 - *pfull =3D &env_tlb(env)->d[mmu_idx].fulltlb[index]; + *pfull =3D full =3D &env_tlb(env)->d[mmu_idx].fulltlb[index]; + flags |=3D full->slow_flags[access_type]; =20 /* Fold all "mmio-like" bits into TLB_MMIO. This is not RAM. */ if (unlikely(flags & ~(TLB_WATCHPOINT | TLB_NOTDIRTY))) { @@ -1744,6 +1753,8 @@ static bool mmu_lookup1(CPUArchState *env, MMULookupP= ageData *data, CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr =3D tlb_read_idx(entry, access_type); bool maybe_resized =3D false; + CPUTLBEntryFull *full; + int flags; =20 /* If the TLB entry is for a different page, reload and try again. */ if (!tlb_hit(tlb_addr, addr)) { @@ -1757,8 +1768,12 @@ static bool mmu_lookup1(CPUArchState *env, MMULookup= PageData *data, tlb_addr =3D tlb_read_idx(entry, access_type) & ~TLB_INVALID_MASK; } =20 - data->flags =3D tlb_addr & TLB_FLAGS_MASK; - data->full =3D &env_tlb(env)->d[mmu_idx].fulltlb[index]; + full =3D &env_tlb(env)->d[mmu_idx].fulltlb[index]; + flags =3D tlb_addr & (TLB_FLAGS_MASK & ~TLB_FORCE_SLOW); + flags |=3D full->slow_flags[access_type]; + + data->full =3D full; + data->flags =3D flags; /* Compute haddr speculatively; depending on flags it might be invalid= . */ data->haddr =3D (void *)((uintptr_t)addr + entry->addend); =20 --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185133; cv=none; d=zohomail.com; s=zohoarc; b=Re1D1RJg4LSiY2ygHs9ZIK1aM3odLPlVjFo8Xl/6ZZh1q+HDnbKra1FpqmIvvmuYPi70PIv8XPWnxjBNaNJgxV3LenmFOCVjNy4W/VZbSYHkAvkDQnMCy/odI60yYj3E0UIKONjoqn7tG9VX3OA+/A0sxapcax7Kba8Ze76N50w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185133; h=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; bh=1INiv+c7X4ecZzReDySXjMWltTGp1DftJNOlKz8t3fU=; b=HTiY138XkfjviHzZljXXacHdyjXkpLcX4CdID3SPBjnqyiZdYIgm12FGSZ/MI3ZQwZMVeRaJsHHsgZYTKh0psfHG+YWfhke6L7n9aAB4ltO9VQCHhrZax6oLbwE1T0CUCaFzvuwJlkOsrn79hYNSJ1z/5iousgnup4DrrNIMllc= 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 1677185133352789.7456649917198; Thu, 23 Feb 2023 12:45:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRa-0002nl-Pe; Thu, 23 Feb 2023 15:43:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRZ-0002mo-DW for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:57 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRX-0007Qw-PL for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:57 -0500 Received: by mail-pj1-x1029.google.com with SMTP id il18-20020a17090b165200b0023127b2d602so569464pjb.2 for ; Thu, 23 Feb 2023 12:43:55 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:43:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1INiv+c7X4ecZzReDySXjMWltTGp1DftJNOlKz8t3fU=; b=Ud/t8ow4GQj/uSb8gvLZAv5jJV1mOrVkIVsK8xaGEaIlRHxKMYvw7p4jL1/yZ4Kak9 BITcFUi8U7PIrHn+lG+sPrs8GN9zABh97HTxlslCKUvWcA5OuRU+53FHCFmbD2SSM5kf SRT+hS+CoXDA3bNefLv2UFldXcQdvxcN5ZfIbavgF7st7PySfROvZCIseDEpLFo6oQF4 H+SguAYlxIxK4qNpgPZQhwd9lLfntdzWc4twrP92qYp0BsVDB23tXAc7Q+dgV0NgGHTs 9ukSAFRM+f72dhbaklI1y7g1c5+50/uZFo3OCeJBa12oeexqmQRqh2va2GXWdU/Extyn UBYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1INiv+c7X4ecZzReDySXjMWltTGp1DftJNOlKz8t3fU=; b=D+CJ/Ux/+Uw2EPHh+Jx/02ZwfSmuHNZu2vISHhPZejy3qX38A4+KkAyQPNfn8c2ysv Hl5JKzw3EyDRBbdpQb38JIqQRJeppGenMrbo6FrPiPivi4Ya4Q35UIRAvC6EsAPTAOtg yJ04RQG4jJCBWOoL9InYDgnsWj+LZ3giWzd9xaa8SlkZ30uNns4fd19J9t/JqkjlGu+r ZBRpDYJJV1PcSmGmkUPv+gp/1jHTImPuT1I44FNsO34GS0nfg38wIMjUjnKkHc6HK8EL JsQKzJEcyV0Cf++pEtI76lauZxC/pfPkq2LessOn3ZM26jFEA/1VvnsOF812ZjW3LJ6o Nl/A== X-Gm-Message-State: AO0yUKVeovgB7KhW4En0WWjwMZZLgQAvkiHFd/1fJ3Cxj/FIstY7qT5p M6vuHbhRrYtO7Bhbbr7T3s8x6DUa7A2BQFqPr/M= X-Google-Smtp-Source: AK7set/+hNJMnBBE9MFxzB7K+Znf3NkQTXMuighcKJb7pBGkvL9/HTljxlwi3lHPhyfNBwZq8N8/NQ== X-Received: by 2002:a05:6a20:3d8b:b0:c7:4c1a:3e43 with SMTP id s11-20020a056a203d8b00b000c74c1a3e43mr10711126pzi.26.1677185034268; Thu, 23 Feb 2023 12:43:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 04/13] accel/tcg: Honor TLB_DISCARD_WRITE in atomic_mmu_lookup Date: Thu, 23 Feb 2023 10:43:33 -1000 Message-Id: <20230223204342.1093632-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185134873100001 Content-Type: text/plain; charset="utf-8" Using an atomic write or read-write insn on ROM is basically a happens-never case. Handle it via stop-the-world, which will generate non-atomic serial code, where we can correctly ignore the write while producing the correct read result. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- accel/tcg/cputlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index e9848b3ab6..74ad8e0876 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1974,7 +1974,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, tar= get_ulong addr, } =20 /* Notice an IO access or a needs-MMU-lookup access */ - if (unlikely(tlb_addr & TLB_MMIO)) { + if (unlikely(tlb_addr & (TLB_MMIO | TLB_DISCARD_WRITE))) { /* There's really nothing that can be done to support this apart from stop-the-world. */ goto stop_the_world; --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185193; cv=none; d=zohomail.com; s=zohoarc; b=OmmtjKNeLZTtyeC5fKVtXPvYKvVh6xNWKWrA1JGs8iMNRkN0WmypWaUgqUmlsqbKznuiplRSNQUzl3ATreHZaR+b3tsOeb6XOHa5qHSNsrTt+MiQMXbCabt2Lu89TSPGqVfsdjsGBL5LWj/fSQNe6PuxFVM2OOQ3hid1GY/eRJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185193; h=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; bh=uCfgSwaCWGjVH4XmiAS5xzTjPaTu2Mc57Kv2qaU5lRM=; b=Cec1c59M0wAdo5HO1fO39GHUVc8U5p/LoBMK5kez/6dQR25fmAuRO3p44MDgVPQELI9LST1HptvG7Q5t6iCOVeJCc4b65RcHtK4ifH/gQVuwiF+LMQoMQznuzAEQn6a9onSYzsABYaHobaPO6sO+LH3flcjGK9QryRwrYnwPlIc= 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 1677185193108421.10865212444673; Thu, 23 Feb 2023 12:46:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRc-0002oz-ED; Thu, 23 Feb 2023 15:44:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRa-0002nj-Mo for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:58 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRZ-0007RI-3M for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:43:58 -0500 Received: by mail-pj1-x102b.google.com with SMTP id u10so14349975pjc.5 for ; Thu, 23 Feb 2023 12:43:56 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:43:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uCfgSwaCWGjVH4XmiAS5xzTjPaTu2Mc57Kv2qaU5lRM=; b=n89/wfw9eZdbECZlYDz5DfRTWcaLs9CRGk61ZLnt0wYLe7RkvzUXWZxy/qVdfS/xMx jhsvJk5jAkHNTzM81PI0a2bQQTbAZvfnVX8sAfjjaNeQsDs4wj0zY/cwXWeHTiefiCab LKLWuP/9XG+VMZ4JnJ5xrnl5S+WFM3XgAXMW3c/f8WuxGqF5jLknWA8HkHqCRJpRw/wJ fF0P+VrmAlNGpOZI5BCoMTEDk5mXgU4pN+OP5Sdrd9UUPfchmR81q3hbglvMBN5bOSUy cV1N3zw+lSJPnew/CiLPXvFrEaqiZDMYaQLK2t4Hy0JAmDl6ATXosa0QSXk15skr8h/R R/Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uCfgSwaCWGjVH4XmiAS5xzTjPaTu2Mc57Kv2qaU5lRM=; b=Z2bqDraQtrwppEr55IV59HgG/NmTglEt1SFOTulxgkN7jailwYWR9q1Oh6HMmaYWpR 2p0lc6bHSkAEKVBJ5P/E+++bB4fdJ1E7kYCqcmC+1K4rN5SVu8j05CUcwN93tElrmsoU H0aOZ8MaHDJCRbl/LVy7tB5yr1709UwXNzSLuutKGgEQsib8byMCN3lFyniZGCIYsjuS LMnJLa+G2FjAke/xCpZTEpaVZ+Aq3UpxPXWoAC6kOP+1AqDymqmCxrUDG087VcfqJc11 7evhcFGodEZBJyr9C8+16Z03+qLSY2PyyLWdBFGMZX94L4w17e4k2PypgTGPZYAhSrsI HHpw== X-Gm-Message-State: AO0yUKVnITNzBuYDD/XSYHCOuJ3oBuuR+Jswnd0/w7pTStbER0atViVF jGqfcaCN7MKiRMvGQNYPvb0QT6/orS2RMXGKOfk= X-Google-Smtp-Source: AK7set/P6uf9waCngUWogIlu0jEd4Mzre3GjzCXAt81YqxLvrCKfPWs0GlDhGNQWaWMVNaq6q3f8XA== X-Received: by 2002:a17:90b:38c7:b0:234:a88e:d67e with SMTP id nn7-20020a17090b38c700b00234a88ed67emr14757191pjb.34.1677185035744; Thu, 23 Feb 2023 12:43:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 05/13] softmmu/physmem: Check watchpoints for read+write at once Date: Thu, 23 Feb 2023 10:43:34 -1000 Message-Id: <20230223204342.1093632-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185195250100003 Content-Type: text/plain; charset="utf-8" Atomic operations are read-modify-write, and we'd like to be able to test both read and write with one call. This is easy enough, with BP_MEM_READ | BP_MEM_WRITE. Add BP_HIT_SHIFT to make it easy to set BP_WATCHPOINT_HIT_*. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 7 ++++--- softmmu/physmem.c | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 2417597236..2f85ba14b3 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -921,9 +921,10 @@ void cpu_single_step(CPUState *cpu, int enabled); #define BP_GDB 0x10 #define BP_CPU 0x20 #define BP_ANY (BP_GDB | BP_CPU) -#define BP_WATCHPOINT_HIT_READ 0x40 -#define BP_WATCHPOINT_HIT_WRITE 0x80 -#define BP_WATCHPOINT_HIT (BP_WATCHPOINT_HIT_READ | BP_WATCHPOINT_HIT_WRIT= E) +#define BP_HIT_SHIFT 6 +#define BP_WATCHPOINT_HIT_READ (BP_MEM_READ << BP_HIT_SHIFT) +#define BP_WATCHPOINT_HIT_WRITE (BP_MEM_WRITE << BP_HIT_SHIFT) +#define BP_WATCHPOINT_HIT (BP_MEM_ACCESS << BP_HIT_SHIFT) =20 int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags, CPUBreakpoint **breakpoint); diff --git a/softmmu/physmem.c b/softmmu/physmem.c index cb998cdf23..c4f62dee60 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -915,9 +915,12 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, v= addr len, /* this is currently used only by ARM BE32 */ addr =3D cc->tcg_ops->adjust_watchpoint_address(cpu, addr, len); } + + assert((flags & ~BP_MEM_ACCESS) =3D=3D 0); QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { - if (watchpoint_address_matches(wp, addr, len) - && (wp->flags & flags)) { + int hit_flags =3D wp->flags & flags; + + if (hit_flags && watchpoint_address_matches(wp, addr, len)) { if (replay_running_debug()) { /* * replay_breakpoint reads icount. @@ -936,16 +939,14 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, = vaddr len, replay_breakpoint(); return; } - if (flags =3D=3D BP_MEM_READ) { - wp->flags |=3D BP_WATCHPOINT_HIT_READ; - } else { - wp->flags |=3D BP_WATCHPOINT_HIT_WRITE; - } + + wp->flags |=3D hit_flags << BP_HIT_SHIFT; wp->hitaddr =3D MAX(addr, wp->vaddr); wp->hitattrs =3D attrs; =20 - if (wp->flags & BP_CPU && cc->tcg_ops->debug_check_watchpoint = && - !cc->tcg_ops->debug_check_watchpoint(cpu, wp)) { + if (wp->flags & BP_CPU + && cc->tcg_ops->debug_check_watchpoint + && !cc->tcg_ops->debug_check_watchpoint(cpu, wp)) { wp->flags &=3D ~BP_WATCHPOINT_HIT; continue; } --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185200; cv=none; d=zohomail.com; s=zohoarc; b=SIyzfBHKVzDZDxKt7w56TqKssUHAtfbbaurqfBm0tQxYRBsdEMBhzleMlZKDVUUCOeYfk0k2W7EZTu/SvAUTxW6L0OOwqlKVsiasWfaP9u1ij5pTbSEwIW3SfiGcx5wOWOwVtDExqMA5rWA9OGei3pSB73/umOvRD9czyiC6lgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185200; h=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; bh=fgeja5IA7DWdfWMaQJS17wRQUp+VgamC4WOakECeEuY=; b=bg50JpsNwFULEmohIbuQIKaZObVx9iLDef0f0gpWHxCy68WMsvc2a7JmLt4dJyxnD6c8JpF1XAn630WPa5+QZ3LKSdZQ5nHtrb8D5GIdARD4fTCbe2a3x7+gdJS2TqrsQmbTXdIECLQtfX7/dDURq0xCwERPb9ASEl8dGXXFM8M= 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 1677185200707119.10142590158978; Thu, 23 Feb 2023 12:46:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRe-0002pa-0Z; Thu, 23 Feb 2023 15:44:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRc-0002oj-8g for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:00 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRa-0007Ro-NB for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:00 -0500 Received: by mail-pj1-x1034.google.com with SMTP id l1so3997451pjt.2 for ; Thu, 23 Feb 2023 12:43:58 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fgeja5IA7DWdfWMaQJS17wRQUp+VgamC4WOakECeEuY=; b=ir9tHoG4bsr+QA+SyzdOL6EpVyYOzyabKXIYOwVIjI+DLC1zDMGmBvcVFICgy1dMPC OzT7anpVeng+qdQ16ZWbBoR11q3BURhdZOx9Bxel2EAc7hKSVi1KF3ZpwBGhyFZk+egH DZOFlzPbhCXc+dREWssE+sXJrZIp4qsjHLiItw0JsGhxMwQxfwPKi+oRXF2wzWLpsYiR w4gwUpME0YtbHrvX7lIOoioQIdgfG6eaqHaqv8aTJlj1wSG0NyGiA4wDZf9mL3VgbkgR 7jSUmqil0NeSwfijuTMyZA8wIBuSjSsinzi3cb1Zj/mHUTKqwbhxLEiEJtUQk1SMZvBi MxqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fgeja5IA7DWdfWMaQJS17wRQUp+VgamC4WOakECeEuY=; b=fU/+kTNv3hTfBFGrlkpulIJ0N2PjNd/2QAqpfk8laaBTtmgMrS2P5uUKZTjyYBGu0f EX6QKM88a0eRYRvtwwBCnQg5Pu3zX8s7D8T6yH+XECX0K9PVy/ROkOtIUyOxcf9R0MSP 1Yw+b5QSaqhcetcGoXKtjpDeRtwkpM0eLCmjjT2D5/50p4QAusx+Cv/WAidPDMPIRqbT IjHivT6TIMSOSXpY13GXtARx24JOmdF74Mv9m+R2kB0xmPBJHBWgOObhCZFd4kVtdGs8 COOGiOGzuxBsyjQwXzLmSSbdfCf1NkVv887TTm4XjUYKhTlHQVuSKmxpnJWz3TKYGqGm pW5w== X-Gm-Message-State: AO0yUKWGR5/+40FualJGDymzIDgKSYXv7wk4PWuX49nH4W8OoN9Snl0b N4hvzjPMovKaitipq5q5BeGTVlPzKDAtXzv6J68= X-Google-Smtp-Source: AK7set+SE06g4w/5GsRPAi3PPr3wa4Cm7AylXnZ9HyxqNK9qNKJ+g64D23lpm/imRg7BKiIRSZMDJQ== X-Received: by 2002:a05:6a20:3d81:b0:cc:32aa:8570 with SMTP id s1-20020a056a203d8100b000cc32aa8570mr2804404pzi.14.1677185037488; Thu, 23 Feb 2023 12:43:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 06/13] accel/tcg: Trigger watchpoints from atomic_mmu_lookup Date: Thu, 23 Feb 2023 10:43:35 -1000 Message-Id: <20230223204342.1093632-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185201256100001 Content-Type: text/plain; charset="utf-8" Fixes a bug in that we weren't reporting these changes. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- accel/tcg/cputlb.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 74ad8e0876..e0765c8c10 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1908,6 +1908,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, tar= get_ulong addr, CPUTLBEntry *tlbe; target_ulong tlb_addr; void *hostaddr; + CPUTLBEntryFull *full; =20 tcg_debug_assert(mmu_idx < NB_MMU_MODES); =20 @@ -1947,17 +1948,26 @@ static void *atomic_mmu_lookup(CPUArchState *env, t= arget_ulong addr, tlb_addr =3D tlb_addr_write(tlbe) & ~TLB_INVALID_MASK; } =20 - /* Let the guest notice RMW on a write-only page. */ - if ((prot & PAGE_READ) && - unlikely(tlbe->addr_read !=3D (tlb_addr & ~TLB_NOTDIRTY))) { - tlb_fill(env_cpu(env), addr, size, - MMU_DATA_LOAD, mmu_idx, retaddr); + if (prot & PAGE_READ) { /* - * Since we don't support reads and writes to different addres= ses, - * and we do have the proper page loaded for write, this shoul= dn't - * ever return. But just in case, handle via stop-the-world. + * Let the guest notice RMW on a write-only page. + * We have just verified that the page is writable. + * Subpage lookups may have left TLB_INVALID_MASK set, + * but addr_read will only be -1 if PAGE_READ was unset. */ - goto stop_the_world; + if (unlikely(tlbe->addr_read =3D=3D -1)) { + tlb_fill(env_cpu(env), addr, size, + MMU_DATA_LOAD, mmu_idx, retaddr); + /* + * Since we don't support reads and writes to different + * addresses, and we do have the proper page loaded for + * write, this shouldn't ever return. But just in case, + * handle via stop-the-world. + */ + goto stop_the_world; + } + /* Collect TLB_WATCHPOINT for read. */ + tlb_addr |=3D tlbe->addr_read; } } else /* if (prot & PAGE_READ) */ { tlb_addr =3D tlbe->addr_read; @@ -1981,10 +1991,18 @@ static void *atomic_mmu_lookup(CPUArchState *env, t= arget_ulong addr, } =20 hostaddr =3D (void *)((uintptr_t)addr + tlbe->addend); + full =3D &env_tlb(env)->d[mmu_idx].fulltlb[index]; =20 if (unlikely(tlb_addr & TLB_NOTDIRTY)) { - notdirty_write(env_cpu(env), addr, size, - &env_tlb(env)->d[mmu_idx].fulltlb[index], retaddr); + notdirty_write(env_cpu(env), addr, size, full, retaddr); + } + + if (unlikely(tlb_addr & TLB_WATCHPOINT)) { + QEMU_BUILD_BUG_ON(PAGE_READ !=3D BP_MEM_READ); + QEMU_BUILD_BUG_ON(PAGE_WRITE !=3D BP_MEM_WRITE); + /* therefore prot =3D=3D watchpoint bits */ + cpu_check_watchpoint(env_cpu(env), addr, size, + full->attrs, prot, retaddr); } =20 return hostaddr; --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185115; cv=none; d=zohomail.com; s=zohoarc; b=h67Yd8GLviiiWl/25QLmkM0r1QTcRPls9/UAelajQa2iXSSEAjQQM0ncQY/ExsA5dqXSrp3KWkCexTb8n6Jaz8brKBOyNMynwYU89RsnTLNlyYm/Vrj89THz1fc0rLJfcjSyKQtr1rHTjN+BVIUGo4zoUzmcw+KHLcnl1auxAWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185115; h=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; bh=adwGVUESBK0GEWMpzNl1mlsUbwgbVqsJeAYNIU7i/OU=; b=JuFFrGFi6AmppmegcH+/9xpmbdJ8mhBXjn2Ph+Q1xJjlgaOViPk6dclPkRqg37g16rrriMJxuYNPQxdgaWEMWC/g9qaVbF3kFqNKRZWdyV4r0/2X+U32WcZ/roSgt50ZzhRyEdR9bnSngdBnD9zgl4BWaoMPHxsXwlSIRKO3CS8= 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 1677185115335179.81392668022409; Thu, 23 Feb 2023 12:45:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRf-0002r0-MA; Thu, 23 Feb 2023 15:44:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRe-0002pb-18 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:02 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRc-0007S9-EZ for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:01 -0500 Received: by mail-pj1-x102b.google.com with SMTP id q31-20020a17090a17a200b0023750b69614so548065pja.5 for ; Thu, 23 Feb 2023 12:44:00 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:43:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=adwGVUESBK0GEWMpzNl1mlsUbwgbVqsJeAYNIU7i/OU=; b=BvWh+IpmMml1i+Nu1Wle7Htn4k1RH/mRH2y+RivLcJSfyIsgDvB3S/Hzq8x4DzRRnK u+KdyGtKaOgtk1v7oGIH3X0D5wybu1UOM/uBXbwrumbr0Aze/7bPs/ZSnfpfoWxlIOKh JYQPvuQ08gf43mQcV/q2EJhU91Cathv9UfWXhubK95I+OssCv66l3kHt+9tTVhV8yC7W OnoIpNAIrK5qAPWAm/uGSuU02oAeVqcuYZTbw3F374tzbYx8pD4UuwoOGTDdGqdSa51k gHcoht6N1bBWx9hoQgtAZc8bddSkAlQrV+b999U6l0OMlEpUNGIanX8oQrrCPUTMMNND DnCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=adwGVUESBK0GEWMpzNl1mlsUbwgbVqsJeAYNIU7i/OU=; b=SObU76fNd2C2wAWZF7+7gfQs4n8rJBVh8Lyi9fTkeA4+gaKTw7gwHZZ5+7sEhMxo2m rE+HfGs/hZIUMv0TRe6WIUxefhAAHkjeZmPGuUZHQ+yOP7N/pTsWqV+zToHGBizzO2zK MOf0TdT2jv0jzhQKUr1PhnLyq/bnQlCGtbPJDc7a7VZH8sBgLXV9Ksv4rLRza4g94Myn QDNO8LsYoSQmRA7Nhcska16fx3501sIwhJLh1otWXcJqFG7eEeI0Qa1GeSOaY2Xuh7wl GxKwPBIIHOIV2HSHCsU0zGT5aAQHiH6+gFvMFxlWv3NqXGUkP1ykFl5ac5qi+2zfSBGt ntPQ== X-Gm-Message-State: AO0yUKUh+lYrrLX2td7/q8OprqQVv6hoQ0Z7cZhXsRwA8MJGZRpC7nqu 1dETQsYF4SM9eMLb88hbQjAHLEmpHXyqZKJBsGk= X-Google-Smtp-Source: AK7set8tePRjwvDOhhcfzMtR10MM8VQZ+XRRVm1ROs83TNVZpyvqfT6Lhedruro1GkIbFpQ1kIWKjw== X-Received: by 2002:a05:6a20:3d81:b0:be:da1c:df65 with SMTP id s1-20020a056a203d8100b000beda1cdf65mr15333638pzi.28.1677185038910; Thu, 23 Feb 2023 12:43:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 07/13] accel/tcg: Move TLB_WATCHPOINT to TLB_SLOW_FLAGS_MASK Date: Thu, 23 Feb 2023 10:43:36 -1000 Message-Id: <20230223204342.1093632-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185116815100001 Content-Type: text/plain; charset="utf-8" This frees up one bit of the primary tlb flags without impacting the TLB_NOTDIRTY logic. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 12 ++++++------ accel/tcg/cputlb.c | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 080cb3112e..f3b2f4229c 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -378,12 +378,10 @@ CPUArchState *cpu_copy(CPUArchState *env); #define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS_MIN - 2)) /* Set if TLB entry is an IO callback. */ #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 writes ignored. */ +#define TLB_DISCARD_WRITE (1 << (TARGET_PAGE_BITS_MIN - 4)) /* Set if the slow path must be used; more flags in CPUTLBEntryFull. */ #define TLB_FORCE_SLOW (1 << (TARGET_PAGE_BITS_MIN - 5)) -/* Set if TLB entry writes ignored. */ -#define TLB_DISCARD_WRITE (1 << (TARGET_PAGE_BITS_MIN - 6)) =20 /* * Use this mask to check interception with an alignment mask @@ -391,7 +389,7 @@ CPUArchState *cpu_copy(CPUArchState *env); */ #define TLB_FLAGS_MASK \ (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO \ - | TLB_WATCHPOINT | TLB_FORCE_SLOW | TLB_DISCARD_WRITE) + | TLB_FORCE_SLOW | TLB_DISCARD_WRITE) =20 /* * Flags stored in CPUTLBEntryFull.slow_flags[x]. @@ -399,8 +397,10 @@ CPUArchState *cpu_copy(CPUArchState *env); */ /* Set if TLB entry requires byte swap. */ #define TLB_BSWAP (1 << 0) +/* Set if TLB entry contains a watchpoint. */ +#define TLB_WATCHPOINT (1 << 1) =20 -#define TLB_SLOW_FLAGS_MASK TLB_BSWAP +#define TLB_SLOW_FLAGS_MASK (TLB_BSWAP | TLB_WATCHPOINT) =20 /* The two sets of flags must not overlap. */ QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & TLB_SLOW_FLAGS_MASK); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index e0765c8c10..cc98df9517 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1966,7 +1966,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, tar= get_ulong addr, */ goto stop_the_world; } - /* Collect TLB_WATCHPOINT for read. */ + /* Collect tlb flags for read. */ tlb_addr |=3D tlbe->addr_read; } } else /* if (prot & PAGE_READ) */ { @@ -1997,12 +1997,21 @@ static void *atomic_mmu_lookup(CPUArchState *env, t= arget_ulong addr, notdirty_write(env_cpu(env), addr, size, full, retaddr); } =20 - if (unlikely(tlb_addr & TLB_WATCHPOINT)) { - QEMU_BUILD_BUG_ON(PAGE_READ !=3D BP_MEM_READ); - QEMU_BUILD_BUG_ON(PAGE_WRITE !=3D BP_MEM_WRITE); - /* therefore prot =3D=3D watchpoint bits */ - cpu_check_watchpoint(env_cpu(env), addr, size, - full->attrs, prot, retaddr); + if (unlikely(tlb_addr & TLB_FORCE_SLOW)) { + int wp_flags =3D 0; + + if ((prot & PAGE_WRITE) && + (full->slow_flags[MMU_DATA_STORE] & TLB_WATCHPOINT)) { + wp_flags |=3D BP_MEM_WRITE; + } + if ((prot & PAGE_READ) && + (full->slow_flags[MMU_DATA_LOAD] & TLB_WATCHPOINT)) { + wp_flags |=3D BP_MEM_READ; + } + if (wp_flags) { + cpu_check_watchpoint(env_cpu(env), addr, size, + full->attrs, wp_flags, retaddr); + } } =20 return hostaddr; --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185162; cv=none; d=zohomail.com; s=zohoarc; b=gx8fJeMcFf1cNJH9Heg4zbY2qV6AWe7AclFYqpCaOXaKTksFCCrwXFb/Y0UyI+0BQxmJHqbkRBTUui9S7mea28sTW25QNCF+19Cqa/KW/F0cdhoG5UGBLRqQpVAA5N6utbsLsNqbZEqDFNrFLeI9fC24LRgzzp0tf2mYvGBDf0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185162; h=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; bh=3vtvNlB4KTNEcDi5rbGBEAocvCMMZzxXPOlMmxtkjOc=; b=Hld64Al1SJ96vAOMvsXGrgnFPQHYY59oo7lMJX780pwHyix1qpVcySQKjIsINenjSS7OGRm7dtpB1Badp9pLV8qyz7AkFAEDuJkgQWGywFfuTJrU5yVyinQr4EhUWZ1gl1/SIxq6feI1h6tqNATbKSHh+wlBmJu84G37aIErhjI= 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 1677185162666552.1220907033874; Thu, 23 Feb 2023 12:46:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRg-0002rm-GB; Thu, 23 Feb 2023 15:44:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRf-0002qg-6x for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:03 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRd-0007QW-3n for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:02 -0500 Received: by mail-pl1-x633.google.com with SMTP id q11so14829922plx.5 for ; Thu, 23 Feb 2023 12:44:00 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3vtvNlB4KTNEcDi5rbGBEAocvCMMZzxXPOlMmxtkjOc=; b=NSQT5MrpMsF68BQuPoeYqbBBT7RfjJU9ERQAbllouaUrLKqG9rAzQ7BhXeqRebuK+L bYxWxzbHD5gOaHTE1TgnKzrTPbyM+k7N7UXxPutqodE6Jza+wSMnJVRkDQVP2DV9xnZq 66cjzOuYrAl/Yxa0W6/ikb9O3wQna9KwblBZr4Jv2CZlkLm4VsY6tMk9lVJLufGDuZk5 hstV8G7GnKkK1Jm/WQI+RokDUqDiHGyudnwSG2o11pbuMxpnKyj8DD8BSDK6Q1r21azX rf0hDW4BAsbdsgVHULfjcR1GzKn68H2ANdqdsJRVBhZeIcxGRX++8W4/cdy8MdeBNGRT 1DRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3vtvNlB4KTNEcDi5rbGBEAocvCMMZzxXPOlMmxtkjOc=; b=f7BCysPPSMmDDy+5WloeQIbh9uHPDXcl2s8AUaZJTlwacMR46JMIDlMcNsQUKa/z8y /9vHcsnUfJFr9a4VAiBs7bxkGk8S7FLlkII9+V+gJBt8XOuHyTs6yfv6L++IUd3LIvf2 U664FU0Hm+RdAroJeUn9S7P0PB/mwn5gW0UoI2ByJM/2nECJ30ouk6Wn7rhXQ++4L8ky Ujieu/MZnhNxKwCKcIQB1JoZi+QypGXFlxIuVB19CaXsxG44kCVVBuZCCFOTzeOpts4u CEhTuCn4+iqP4ksXKApbyD5WyZFjQqr0uQP52QqYHCsjDcBqp5LcqkIuPko6GqZcyZNN TxXA== X-Gm-Message-State: AO0yUKUOhjelT0S8V+JgX7CdfTJwscyY3obRbLsaFL9o3Nqqq09ezx2Y xE4MrooPJfeq8+MFPYHRD9BdtocqaFQgsv3U3u8= X-Google-Smtp-Source: AK7set8HYUjgYVHXAsilgr00Xt+daIFSG5riR7Le5Y763WfGTN+WOklFBTwmc1Bj8Ck+luE+AOTILQ== X-Received: by 2002:a05:6a20:8f05:b0:cb:8d74:1114 with SMTP id b5-20020a056a208f0500b000cb8d741114mr11744034pzk.44.1677185040354; Thu, 23 Feb 2023 12:44:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 08/13] target/arm: Support 32-byte alignment in pow2_align Date: Thu, 23 Feb 2023 10:43:37 -1000 Message-Id: <20230223204342.1093632-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185163078100001 Content-Type: text/plain; charset="utf-8" Now that we have removed TARGET_PAGE_BITS_MIN-6 from TLB_FLAGS_MASK, we can test for 32-byte alignment. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/translate.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index c23a3462bf..412fc4aca8 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -940,13 +940,7 @@ static inline void store_reg_from_load(DisasContext *s= , int reg, TCGv_i32 var) MemOp pow2_align(unsigned i) { static const MemOp mop_align[] =3D { - 0, MO_ALIGN_2, MO_ALIGN_4, MO_ALIGN_8, MO_ALIGN_16, - /* - * FIXME: TARGET_PAGE_BITS_MIN affects TLB_FLAGS_MASK such - * that 256-bit alignment (MO_ALIGN_32) cannot be supported: - * see get_alignment_bits(). Enforce only 128-bit alignment for no= w. - */ - MO_ALIGN_16 + 0, MO_ALIGN_2, MO_ALIGN_4, MO_ALIGN_8, MO_ALIGN_16, MO_ALIGN_32 }; g_assert(i < ARRAY_SIZE(mop_align)); return mop_align[i]; --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185233; cv=none; d=zohomail.com; s=zohoarc; b=l3N1IvYe3hZ9gptfEkVQWItC79IFHrcl+1mkZ1MPs1kbE8OgFP2+IhdkhDYuwLyX4kN0fGa7eaJR1/Ik8uC0+TecGZ/vmRUyUHT/ujWMtwBzKQOnRfGP43lZnClI5OazJYUjt5sweWA/WrDAmGiqmlhfWDMhGjcughtTqOz836o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185233; h=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; bh=1DH8GytkPurA9HrZaN37YWqxqd2398SYcw6ExGS87Do=; b=J8T0M+4EZGQPiu+dF01wh/iF0H8icos0qARk0iw3RQWGSxQOmBgcpu9iHLE1gy+CsDlylaIrT43RXknpm8rruGJM+7FVTQF2rGtikzMSzuVhdfdEH+AWGRxOfaZxe1erWUcatzTb1U4WGBqf1lVAwbj2hSlW3uhJL4ve2Cd5twg= 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 1677185233789613.5686088718836; Thu, 23 Feb 2023 12:47:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRj-0002te-3X; Thu, 23 Feb 2023 15:44:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRg-0002rx-PR for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:04 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRf-0007T7-9S for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:04 -0500 Received: by mail-pj1-x1032.google.com with SMTP id pt11so14995497pjb.1 for ; Thu, 23 Feb 2023 12:44:02 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1DH8GytkPurA9HrZaN37YWqxqd2398SYcw6ExGS87Do=; b=XEAP3hiJfXhcMkZwci7Eq88t0pM4bM+B+Hk/UBnOnFyrF0na7znaTQ9a4rSOIBvNI5 m6CpW4LK5DIu3a7cLvgWKAsJDWw+x2Vgb3kS3TCIYA8Ly9Gn1xrjPYnohLn79kWPN8ur fiSahnMRIPsHnkiKZuXHLWKEuiHebwDmw62FJhzPoDB6JJdSWozoo3cuCqIfbfztl+oW FrNzUSLwdn01+j/PkgrNwfCoItLSLPGRj2Ki0VJYRj0C4hXmfWAMkb1FTM7W7WCpoPzg OtRCYuToKb4xVOHqumlSpmCbu7HjW6oECeS13UTfFYxufkO4iccXVJ9FjrIMGhm3ec83 Ssyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1DH8GytkPurA9HrZaN37YWqxqd2398SYcw6ExGS87Do=; b=VBTPdEFfclM4SXjde5QrGj5w1AIhRhK7HAz5cNVYP+c50aEyh8Ei/uR/yR+h2Pddtg Oq5TZnFhB+D8aA3MAywax6YyhRhdVqnF3N27b5Afmu1te3h/a8QcN//VEmKnJAmtzzyi OFfJuEjR5r8ngWXgPBbVykP9LPg0uq/tQAf0pmgKnWCXgefK8Ufq+O/dDeehgcEqOtFr uqTU9/+O/5tVNMTYTojT+FKV5i9VmWBo8x5raSVL/YarkiFLKFmmITtHcU1MjP1CeYOK p9Ghx2cyMagIHdIRVaHjAYHZIfGoS7FMB+NKekdAqsey45wHqluCJOSe9M1qDPYHFOnI fUBQ== X-Gm-Message-State: AO0yUKXTALCKQNhgqweBah0WrNai8e0aflsevfDpFQu/5NVmtJxNpZ0d gSMXB7DcVD8hPlllfbYKIlxo+QIdoIGpvZUsqNA= X-Google-Smtp-Source: AK7set97R923kVQZyuWuSHFxVdW7E6/grwh5ONPGLDjkq6eFuzhopbXT9zQPDbRuADsNIzcjHdQaXA== X-Received: by 2002:a05:6a20:8f10:b0:cb:a66b:3a88 with SMTP id b16-20020a056a208f1000b000cba66b3a88mr10004856pzk.1.1677185041785; Thu, 23 Feb 2023 12:44:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 09/13] exec/memattrs: Remove target_tlb_bit* Date: Thu, 23 Feb 2023 10:43:38 -1000 Message-Id: <20230223204342.1093632-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185235475100003 Content-Type: text/plain; charset="utf-8" These fields are no longer used. Target specific extensions to the page tables should be done with TARGET_PAGE_ENTRY_EXTRA. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/memattrs.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index 9fb98bc1ef..1bd7b6c5ca 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -47,16 +47,6 @@ typedef struct MemTxAttrs { unsigned int requester_id:16; /* Invert endianness for this page */ unsigned int byte_swap:1; - /* - * The following are target-specific page-table bits. These are not - * related to actual memory transactions at all. However, this struct= ure - * is part of the tlb_fill interface, cached in the cputlb structure, - * and has unused bits. These fields will be read by target-specific - * helpers using env->iotlb[mmu_idx][tlb_index()].attrs.target_tlb_bit= N. - */ - unsigned int target_tlb_bit0 : 1; - unsigned int target_tlb_bit1 : 1; - unsigned int target_tlb_bit2 : 1; } MemTxAttrs; =20 /* Bus masters which don't specify any attributes will get this, --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185169; cv=none; d=zohomail.com; s=zohoarc; b=R46UGz9pW3lQdLOAyuy+8KUo62XZdyvUWFODxNBsXRYk8Rstqgh30xcAS2UxgoPilg7J3F/oxQFTxZlRjG8921UAk4FxwLkFsDdz2VihqHlKsTYYtTdVtPZbZFpZsZD5Pfh9BaxD2/F2jkj782eQKwkgszezVNd+MAEkLWASqNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185169; h=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; bh=1qnhwX4yflIrdAFP6huqsV3m6ZntpB/Nux3MPFDNhmI=; b=UeKbk8ni6D9FgSm1gZK/mCK3ZeYIiWvfalREK754vK/9JiadWQHMzs/E3X36aSoYp+txE8nuZ+V8xnfiaHbPD8MI06WHzvdf6YtEaTPQouxi+lWUiWw9yqo0FEkf/62rhTvySleNvRpmFG/kkSy/cNYQKo931EjyC9V1jeNgVnc= 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 1677185169497675.4354421566882; Thu, 23 Feb 2023 12:46:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRk-0002tv-4Q; Thu, 23 Feb 2023 15:44:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRi-0002tB-8t for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:06 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRg-0007To-Hi for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:05 -0500 Received: by mail-pl1-x632.google.com with SMTP id l15so15653875pls.1 for ; Thu, 23 Feb 2023 12:44:04 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1qnhwX4yflIrdAFP6huqsV3m6ZntpB/Nux3MPFDNhmI=; b=e2+Z/XP3GFTAF/aOVg0WIAh+mexIOmxR6DFmL8nqNwpeOGXlbSdc7YSTz8r4M7ToI8 ZWDtc1zQJExswHP5rn0tEKWJBLfpVX0st6uTYnqRiurhfkRgtU++7BVbpEpG5w+3kR88 d99YdhT7AyYfTCdO6XlS1vSV91l/1HUa9jGThgEFxudiIL8FHk59+hxMqJya3DSFuuv6 98JBCWpnq/ZAxFb5UQtEhI8tieMs+jJBh5RgzQYyqFEox4KwYXP+IcZF+M4VDwH0eZ7E 6oBHiVKRuGVo/n8x526VnCe6Jqx1C/WDWOsjx4C9PW11P9c2mI9sK1XDHMME22Y4O6tL GPUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1qnhwX4yflIrdAFP6huqsV3m6ZntpB/Nux3MPFDNhmI=; b=hRZoomptDmLGdVviNHt9PaW60lKcmGz5GZBEYiR62l9wlnqTGNjSOp+YnKsr9oxFF1 uFaWS2w7eAWjHfDQpCNEVq2jtpiTHz/6V6HN9V9t/onKjOtyW1/TxMdFKhNWGpxlkLgW LAwOmD97277Yck1wtx0gWGb4FeFuR3Y0NJaqeeoB2ENDfcKJ7aAD285P0KurCehZ1GdG EcaC4pKdxHz6o5sgax5AQBNmPAW799Z2ebMd/hczoG6bPO3K93fcFP8Ibu41d+c5dX/v HFeSx7suiLsuxkQ3dccDusFNrdt5QK9mS2gUPbmXkbAP1Ux/Zf7zxbCfU1Bg8848aq1m ATuA== X-Gm-Message-State: AO0yUKUA4M4JIwxta5LL6KKKN0Wziq7RdTNcztMUWA84mGm1LReXa6HU hppLHFjiVZVRQKUIo7zKwaydq54EuwgQhyZtx7g= X-Google-Smtp-Source: AK7set97fO0Md7B1toCfjuw+PuUJjCvPvodGYTK+qxmdzfdT925is5PVoKwHT6b+tXZJ/TCMl3/Xyg== X-Received: by 2002:a05:6a20:ba9e:b0:c0:c9b8:56 with SMTP id fb30-20020a056a20ba9e00b000c0c9b80056mr4821871pzb.29.1677185043203; Thu, 23 Feb 2023 12:44:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 10/13] accel/tcg: Add tlb_fill_flags to CPUTLBEntryFull Date: Thu, 23 Feb 2023 10:43:39 -1000 Message-Id: <20230223204342.1093632-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185171153100001 Content-Type: text/plain; charset="utf-8" Allow the target to set tlb flags to apply to all of the comparators. Remove MemTxAttrs.byte_swap, as the bit is not relevant to memory transactions, only the page mapping. Adjust target/sparc to set TLB_BSWAP directly. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/cpu-defs.h | 3 +++ include/exec/memattrs.h | 2 -- accel/tcg/cputlb.c | 5 +---- target/sparc/mmu_helper.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index ef10c625d4..53743ff3f2 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -170,6 +170,9 @@ typedef struct CPUTLBEntryFull { /* @lg_page_size contains the log2 of the page size. */ uint8_t lg_page_size; =20 + /* Additional tlb flags requested by tlb_fill. */ + uint8_t tlb_fill_flags; + /* * Additional tlb flags for use by the slow path. If non-zero, * the corresponding CPUTLBEntry comparator must have TLB_FORCE_SLOW. diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index 1bd7b6c5ca..5300649c8c 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -45,8 +45,6 @@ typedef struct MemTxAttrs { unsigned int memory:1; /* Requester ID (for MSI for example) */ unsigned int requester_id:16; - /* Invert endianness for this page */ - unsigned int byte_swap:1; } MemTxAttrs; =20 /* Bus masters which don't specify any attributes will get this, diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index cc98df9517..a90688ac30 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1168,14 +1168,11 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx, " prot=3D%x idx=3D%d\n", vaddr, full->phys_addr, prot, mmu_idx); =20 - read_flags =3D 0; + read_flags =3D full->tlb_fill_flags; if (full->lg_page_size < TARGET_PAGE_BITS) { /* Repeat the MMU check and TLB fill on every access. */ read_flags |=3D TLB_INVALID_MASK; } - if (full->attrs.byte_swap) { - read_flags |=3D TLB_BSWAP; - } =20 is_ram =3D memory_region_is_ram(section->mr); is_romd =3D memory_region_is_romd(section->mr); diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index a98dd0abd4..fa58b4dc03 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -580,7 +580,7 @@ static int get_physical_address_data(CPUSPARCState *env= , CPUTLBEntryFull *full, int do_fault =3D 0; =20 if (TTE_IS_IE(env->dtlb[i].tte)) { - full->attrs.byte_swap =3D true; + full->tlb_fill_flags |=3D TLB_BSWAP; } =20 /* access ok? */ --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185082; cv=none; d=zohomail.com; s=zohoarc; b=eh4yZxhgV4Jbeioo9ffxh+XipDfblUWH+1QN5LtEaNqhvbeiN5/ZuKt7QBdQ6srBJ/Wh1TeiRleDd4njanuq7WXXP4eRvgB10CS6Yeqj7/YDC+StGeN6+SUDcGiS5cYs3Cr1xvacrWZdGqQ8CCqW2Z3rKOHlhIFUc9fECaBAZyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185082; h=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; bh=yTc8B4JFMt2BP2s8OFGRKyLxOfXJWkbz6vP1/iv9tl8=; b=dGV43VyxGhiSp2+Ep2+U0qNIjUOKO1xWtlOz9vvkCVAJEmweg3v2gl+hikL0v0wQIhk3LSWIK+f2zzHzUAPYctRq30hCBCGy1OEghxQ3GTswIiVKX1O5X/nwVfHtfZjT+EXzGCzZN1BjZZ+0ANaIGJK9Yokcg4+fTJJJrzoUwiU= 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 1677185082864655.6866706493089; Thu, 23 Feb 2023 12:44:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRk-0002wa-QV; Thu, 23 Feb 2023 15:44:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRj-0002ti-GP for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:07 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRh-0007PT-Rc for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:07 -0500 Received: by mail-pl1-x632.google.com with SMTP id e5so15563839plg.8 for ; Thu, 23 Feb 2023 12:44:05 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:44:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yTc8B4JFMt2BP2s8OFGRKyLxOfXJWkbz6vP1/iv9tl8=; b=KtMMPbbnac41HdsjB0iPOxFkQMHlwQmJNk4nxVGxYUcUd0k5e0ViKo4Y6DNICfbS3H sQsmSgF8Lawd5ijlnks0Vuut6+4xtZa1cdW2yqkGu9HJRVN/uXy07qrbZVyA+GEHG9og 5TSc7K6JLFVR/OnTWetN8b+xCqbFwd2QHYhPKTzFSXVh+398ARvZLlDJVNq5QCMTJjOA cn7Yh8ayd62xc57krVEXwgjxXR3SuFRgPE+/bAZrZerMPtruWI8iYNvr/0SbGnTFhH+x frvjzSfyTlk2A9ZelIu5jfC5sMzyJ9P+9Ky9DhnLcj2GCvrG3xLNsu1ohIfe2CX1VuXH 0GKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yTc8B4JFMt2BP2s8OFGRKyLxOfXJWkbz6vP1/iv9tl8=; b=10owN3+nyKau4jS42EKzJsVWXDykoSsRxmMRtL/cBRNqzsYhFmJV4FYRVl84dvnW98 7LbpfFMtAPqASB0wW2WYY1I5Qt6HeW3D3TxjOHHi3GRcb3O6eJXigk/OT8FoqSEZVwyp ll/3se5CuovpM9G3haxA5rwkMeTCv6X+Ff6u3igOQNkVnTNalcEU61bzR8Yv/rDsjfPP 1VlS0EIDwXu7GxC3yyNukL/k2Yvwr4MFPCmLVPmojYxu87fQMCFc9F/2DqVyysKfF6Uy ZzwE1FsVSg3CvK85BW99p3m9lAjM71T3hKsC/YGRmx+g5z8QzYqe8NwSgnLevYG8zwNK +ZbQ== X-Gm-Message-State: AO0yUKU5J2SEtHs7euG3aBontdCZhOQRmeftXgZ1+BlPUksmrG575XYZ VbEoqH+Gij1I1l1/HTQ5oe8ueNbrsE9I5U+FQts= X-Google-Smtp-Source: AK7set+Ber1ERYP1MO2u5xrsxVUVQYJLd2mkg9V8Msue4RxE+cSLMCAfIQnEBEsgbvNmq6Tc+qbSpg== X-Received: by 2002:a17:90b:3847:b0:233:e426:6501 with SMTP id nl7-20020a17090b384700b00233e4266501mr13056943pjb.19.1677185045020; Thu, 23 Feb 2023 12:44:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 11/13] accel/tcg: Add TLB_CHECK_ALIGNED Date: Thu, 23 Feb 2023 10:43:40 -1000 Message-Id: <20230223204342.1093632-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185084358100003 Content-Type: text/plain; charset="utf-8" This creates a per-page method for checking of alignment. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 4 +++- accel/tcg/cputlb.c | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index f3b2f4229c..5bb04782ba 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -399,8 +399,10 @@ CPUArchState *cpu_copy(CPUArchState *env); #define TLB_BSWAP (1 << 0) /* Set if TLB entry contains a watchpoint. */ #define TLB_WATCHPOINT (1 << 1) +/* Set if TLB entry requires aligned accesses. */ +#define TLB_CHECK_ALIGNED (1 << 2) =20 -#define TLB_SLOW_FLAGS_MASK (TLB_BSWAP | TLB_WATCHPOINT) +#define TLB_SLOW_FLAGS_MASK (TLB_BSWAP | TLB_WATCHPOINT | TLB_CHECK_ALIGN= ED) =20 /* The two sets of flags must not overlap. */ QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & TLB_SLOW_FLAGS_MASK); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index a90688ac30..c692e71766 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1546,7 +1546,7 @@ static int probe_access_internal(CPUArchState *env, t= arget_ulong addr, flags |=3D full->slow_flags[access_type]; =20 /* Fold all "mmio-like" bits into TLB_MMIO. This is not RAM. */ - if (unlikely(flags & ~(TLB_WATCHPOINT | TLB_NOTDIRTY))) { + if (flags & ~(TLB_WATCHPOINT | TLB_NOTDIRTY | TLB_CHECK_ALIGNED)) { *phost =3D NULL; return TLB_MMIO; } @@ -1885,6 +1885,29 @@ static bool mmu_lookup(CPUArchState *env, target_ulo= ng addr, MemOpIdx oi, tcg_debug_assert((flags & TLB_BSWAP) =3D=3D 0); } =20 + /* + * This alignment check differs from the one above, in that this is + * based on the atomicity of the operation. The intended use case is + * the ARM memory type field of each PTE, where access to pages with + * Device memory type require alignment. + */ + if (unlikely(flags & TLB_CHECK_ALIGNED)) { + MemOp atmax =3D l->memop & MO_ATMAX_MASK; + MemOp atom =3D l->memop & MO_ATOM_MASK; + MemOp size =3D l->memop & MO_SIZE; + + if (size !=3D MO_8 && atom !=3D MO_ATOM_NONE) { + if (atmax =3D=3D MO_ATMAX_SIZE) { + a_bits =3D size; + } else { + a_bits =3D atmax >> MO_ATMAX_SHIFT; + } + if (addr & ((1 << a_bits) - 1)) { + cpu_unaligned_access(env_cpu(env), addr, type, l->mmu_idx,= ra); + } + } + } + return crosspage; } =20 --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185087; cv=none; d=zohomail.com; s=zohoarc; b=BLwn2DVARbChD2a5qEZm472hObG9TRscjdXKDIut0dyPHaQl0sKeiA88jZ0px2x6lUU3VurGAZJJVWD7FVOcSEU9XCDgWJ/QLkL/h9Wuf+Dyx0L+mS9q0wF9k2SIB84l/KYqfpr5mqNGiMSaSAmtZQoYiYQJLhHtC4yeenEl5fM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185087; h=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; bh=4VpqcMOXVlrjqv2u2QyFnc/vNdrKfYNKBg4oxbaB+0Q=; b=j5nWmnjorNc1Gf6bdBjIJCdjHRb6IWELpIR8y9o5Ge+s81U4CZCPX/UUMaydWps7QpFMoJso65oSW8XbkIbCA3QU3+R9bEvUGEfgAR78SQSmWC0Ie7Xd7fqQWp35c6KHN1D/tPELos/ilo6nysHC5BWe92uvmR6EPIOFCrlhl5U= 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 1677185087581759.5761882333342; Thu, 23 Feb 2023 12:44:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRn-0002yx-D5; Thu, 23 Feb 2023 15:44:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRl-0002yG-SF for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:09 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRk-0007UY-4D for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:09 -0500 Received: by mail-pl1-x644.google.com with SMTP id u14so10582589ple.7 for ; Thu, 23 Feb 2023 12:44:07 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:44:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4VpqcMOXVlrjqv2u2QyFnc/vNdrKfYNKBg4oxbaB+0Q=; b=AeF+e/q1u6JXtK32KfD1tGeD3rTzWOTE9LnYz4oGELCJM5mBGEI71BjB61EQKWLjTu GhaWy0x0Bugy1WnUIv7T7ixAT/3e4biWSymK2/bkfvPn2SbIa0rFcYKOtFv9JJTHUr6j 4MkdEkLBrZwLlEnxyV3aWx0WvofrodjuGgb8JnP8snXqf5XM9I5r2gynqw4NIOzOzj56 T/KZ5oeLtK+0r6hSe9uuZfBGKPsYOp5GQ5W1RXKHSP1aJMOkJgBxcjm71pvgClGFihXp opjHUO/9Hi5x5lCDOTqXJuOCGHw0ygw3uBVr7b5/vlnpLwxhoc+eXzsugl2sMwDsn/Sx Efkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4VpqcMOXVlrjqv2u2QyFnc/vNdrKfYNKBg4oxbaB+0Q=; b=wQ0tbFYeZ7BWoWv6I/8ZxbBTZTsVClw165P0X0LPvB1ALY4IbBfPvFoM1Q5kA767Ec KWsqNaBmzDtKk6Pqe9qI7tt+RO1zA+fImbTX26lBBVq3iVMq2yWRUsxl0IEwTvkr2UuF 7qLCgv8+E+U5CjyXGq3fkO8L33+CYlAzrMP4gO/jBUEVpnJKFEC7X58XMRnPJkESl3pp TphBPkvVWAskwrJJYZlvHQPA2VkA/3KQpxFM1wzJ5JIiqtnptv6IP7iRkVFEkzVBKFQt GaOiMXno/vDJiaL3sw1TRbdrvZ2wOz6lGHJFq0u4yT7zXITynqQjkJisu3sD8EMCHoiV DisQ== X-Gm-Message-State: AO0yUKX882xrpSOVtkeE2ZmPH0qPxAfibivzxLtvwIcBjuggvThobHKd HrdWuac84hbtvLD+XVEylr53T5QZ6vBs4NIKgPOdrA== X-Google-Smtp-Source: AK7set/t/aBuZB9vcZH5dhDvSjapnVQaEZaY6pIrVjQI1paSN2L+LTZUToiXiD7ACBUEe8GZPp4c7w== X-Received: by 2002:a05:6a20:6530:b0:cc:59a7:65ae with SMTP id n48-20020a056a20653000b000cc59a765aemr625929pzg.24.1677185046622; Thu, 23 Feb 2023 12:44:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Idan Horowitz Subject: [PATCH 12/13] target/arm: Do memory type alignment check when translation disabled Date: Thu, 23 Feb 2023 10:43:41 -1000 Message-Id: <20230223204342.1093632-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::644; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x644.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185088411100011 Content-Type: text/plain; charset="utf-8" If translation is disabled, the default memory type is Device, which requires alignment checking. This is more optimially done early via the MemOp given to the TCG memory operation. Reported-by: Idan Horowitz Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1204 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/helper.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 07d4100365..b1b664e0ad 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11867,6 +11867,37 @@ static inline bool fgt_svc(CPUARMState *env, int e= l) FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL1); } =20 +/* + * Return true if memory alignment should be enforced. + */ +static bool aprofile_require_alignment(CPUARMState *env, int el, uint64_t = sctlr) +{ +#ifdef CONFIG_USER_ONLY + return false; +#else + /* Check the alignment enable bit. */ + if (sctlr & SCTLR_A) { + return true; + } + + /* + * If translation is disabled, then the default memory type is + * Device(-nGnRnE) instead of Normal, which requires that alignment + * be enforced. Since this affects all ram, it is most efficient + * to handle this during translation. + */ + if (sctlr & SCTLR_M) { + /* Translation enabled: memory type in PTE via MAIR_ELx. */ + return false; + } + if (el < 2 && (arm_hcr_el2_eff(env) & (HCR_DC | HCR_VM))) { + /* Stage 2 translation enabled: memory type in PTE. */ + return false; + } + return true; +#endif +} + static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el, ARMMMUIdx mmu_idx, CPUARMTBFlags flags) @@ -11936,8 +11967,9 @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState= *env, int fp_el, { CPUARMTBFlags flags =3D {}; int el =3D arm_current_el(env); + uint64_t sctlr =3D arm_sctlr(env, el); =20 - if (arm_sctlr(env, el) & SCTLR_A) { + if (aprofile_require_alignment(env, el, sctlr)) { DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); } =20 @@ -12037,7 +12069,7 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState= *env, int el, int fp_el, =20 sctlr =3D regime_sctlr(env, stage1); =20 - if (sctlr & SCTLR_A) { + if (aprofile_require_alignment(env, el, sctlr)) { DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); } =20 --=20 2.34.1 From nobody Tue May 14 10:11:32 2024 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=1677185156; cv=none; d=zohomail.com; s=zohoarc; b=LuRwKk9N5muiR7PAdCLsytRLplgIJ47/dgJiEfaO+jacDWsnh5ShWa2LCEgtpQ9peNN4+w5he0GmOpZEfpKm0gwhx6h2TDFKIalGtNr7TpSCN4IoXyL7suYkF/TLlgrYQ+F1VazTCUruXSiCLlU+LVS2xV+NREwbWLwfr/IiVro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677185156; h=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; bh=1DYpXgLa7aKwNkf25RMtvRP9iUFACK26xYqqO1SJ46k=; b=cJcQ9oG0tQyEEo0ULy+ZJ3yeoEM2sAExvtIVun7xjwWgpHN70dC6bnMe98WcHrZrRjAbyvDUMzgZSUrY44NFd8GQZOIDqXStqIZUK5On9wv6xAdxQsh3sQZDnfSYEDmQFg8nDFr6fjTDd4dJyR61BczncNdp3fucs2YNkkDDszY= 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 16771851561368.032415419584254; Thu, 23 Feb 2023 12:45:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVIRp-00031r-FM; Thu, 23 Feb 2023 15:44:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVIRn-0002yu-8H for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:11 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVIRl-0007Ut-Cd for qemu-devel@nongnu.org; Thu, 23 Feb 2023 15:44:10 -0500 Received: by mail-pl1-x642.google.com with SMTP id z2so14645700plf.12 for ; Thu, 23 Feb 2023 12:44:08 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id e187-20020a6369c4000000b004b1fef0bf16sm5992850pgc.73.2023.02.23.12.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 12:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1DYpXgLa7aKwNkf25RMtvRP9iUFACK26xYqqO1SJ46k=; b=J9edVt+DQkk4SsCK7WGgpyl7038DZpsJFyk0xkT17XAmYJemHoRyEHJBKrxcZRRtyu K6OsRxo+BnPP0vmWA9tnjJl9myTqinuYiPowQl4pfYf5UDr8cfLzURiVIcQNzRZzDZQ4 FoUMZn6ejtr6B40MdhvWmKFSv5S6H4C3QS7FGu231cNA4lLbouZ+qyVx3+Gzn0diT3VS Z77lXRHFp2/SyoF0XeMQVcw0tXkjYeCu0A98ffqHnAkKGmPP6DP79DmR8I9qdu/At6nd nb9BpJhHFlQj3Nk1HW++Ta8aXXGeS23YuqX4FN8Q5tU7HK9ewKkZO5g6pNXJOhLeC2IU h8/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1DYpXgLa7aKwNkf25RMtvRP9iUFACK26xYqqO1SJ46k=; b=MXmtmSd9bo7De5H8m8HJx4HTRh0Dm4ktqUUTFwtyqAJlSErBmDrL47/bEf8rQaGMLs ksrmm6defcv6M2Pqk63wT3gkutJDG25dv5MDwUpeBtqVVTOse4YVgmRMqe53C4F/tVWt Q1KeXEggNRhHXXd4NkIaweYX3uaBjJ8gxKweBuSr9Kv1tHbhbRTXs3PPRjNZuRdwDCM6 FEe2WS1Yck2VoX+H+aDWCBHz32faCADQi6S3J70x1TgPEhfN8HjVDkH7FKxr9MnqxIjf QaIjllbNadETo3u5iCeVEiQskX8rdKIM9/CpuJQY3Dqzxvb0/41Fh0sILzsUniLfDU+7 gYeA== X-Gm-Message-State: AO0yUKU0vPN62xh00QOIIUFN4ZJpHKJT2Lb82eIrf02JGSJrJQWm9cZt LJt7qk9TO3DDHqv0VUiRMFE81bRvm5vPuG8ZkI2DZA== X-Google-Smtp-Source: AK7set92joUnqdkkpELTPAfC/+JW1kDzlJlmb6sBIw1zBSRRkTr6UjYD3OiUXu86p+znmykJ3K0H8A== X-Received: by 2002:a17:90b:4c50:b0:233:ce0b:8655 with SMTP id np16-20020a17090b4c5000b00233ce0b8655mr13021290pjb.28.1677185048034; Thu, 23 Feb 2023 12:44:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 13/13] target/arm: Do memory type alignment check when translation enabled Date: Thu, 23 Feb 2023 10:43:42 -1000 Message-Id: <20230223204342.1093632-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223204342.1093632-1-richard.henderson@linaro.org> References: <20230223204342.1093632-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::642; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x642.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677185156939100001 Content-Type: text/plain; charset="utf-8" If translation is enabled, and the PTE memory type is Device, enable checking alignment via TLB_CHECK_ALIGNMENT. While the check is done later than it should be per the ARM, it's better than not performing the check at all. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 2b125fff44..19afeb9135 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -194,6 +194,16 @@ static bool regime_translation_disabled(CPUARMState *e= nv, ARMMMUIdx mmu_idx, return (regime_sctlr(env, mmu_idx) & SCTLR_M) =3D=3D 0; } =20 +static bool S1_attrs_are_device(uint8_t attrs) +{ + /* + * This slightly under-decodes the MAIR_ELx field: + * 0b0000dd01 is Device with FEAT_XS, otherwise UNPREDICTABLE; + * 0b0000dd1x is UNPREDICTABLE. + */ + return (attrs & 0xf0) =3D=3D 0; +} + static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs) { /* @@ -1188,6 +1198,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, bool aarch64 =3D arm_el_is_aa64(env, el); uint64_t descriptor, new_descriptor; bool nstable; + bool device; =20 /* TODO: This code does not support shareability levels. */ if (aarch64) { @@ -1568,6 +1579,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, if (regime_is_stage2(mmu_idx)) { result->cacheattrs.is_s2_format =3D true; result->cacheattrs.attrs =3D extract32(attrs, 2, 4); + device =3D S2_attrs_are_device(arm_hcr_el2_eff_secstate(env, is_se= cure), + result->cacheattrs.attrs); } else { /* Index into MAIR registers for cache attributes */ uint8_t attrindx =3D extract32(attrs, 2, 3); @@ -1575,6 +1588,21 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, assert(attrindx <=3D 7); result->cacheattrs.is_s2_format =3D false; result->cacheattrs.attrs =3D extract64(mair, attrindx * 8, 8); + device =3D S1_attrs_are_device(result->cacheattrs.attrs); + } + + /* + * Enable alignment checks on Device memory. + * + * Per R_XCHFJ, this check is mis-ordered, in that this alignment check + * should have priority 30, while the permission check should be next = at + * priority 31 and stage2 translation faults come after that. + * Due to the way the TCG softmmu TLB operates, we will have implicitly + * done the permission check and the stage2 lookup in finding the TLB + * entry, so the alignment check cannot be done sooner. + */ + if (device) { + result->f.tlb_fill_flags |=3D TLB_CHECK_ALIGNED; } =20 /* --=20 2.34.1