From patchwork Wed May 3 07:21:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 678735 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp913869wrs; Wed, 3 May 2023 00:40:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73ps9hWjxO75QxKJeveSU9LsrmHp3q7+riukgQ3M1o0B4hOYS7Fkbz2pR/UTtze1jItM2g X-Received: by 2002:ad4:5f4a:0:b0:5ef:8c79:fe92 with SMTP id p10-20020ad45f4a000000b005ef8c79fe92mr9641204qvg.3.1683099607685; Wed, 03 May 2023 00:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683099607; cv=none; d=google.com; s=arc-20160816; b=cSUqA/qakL7g/pUk6/IRlQ7SHvv26FeV3QGz7Aq0nG2tQiYqwDSuoHmmaWoB1QppaU exsniwWRxiDeRA3byrgFcOEeZQD6e95Acp4EPOI+Sa6Bk/OPTYLES/6B9ENEdIf0CNHd mEJ7xDwNMAmFy2+r45zZ+4RHFWGgW2Fc1E96ONgbSUwsPUMUnnjk2vNgmyWDnuOvI1CV OTOHCe4cAW23fm30G2LBaS/P12IZT7qFfJQBUDtpXKeeEwx18SOhJksNlHCQUn9XViZH 5Zzmo8JqwGTy5zNZc4dzAJzutWHBIZjAncsTp1Fe3FCBWpAexnMOfRRg6yXrDNIy9peR lXQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Hv/l59D9/l35x4T8g8G++KyGPDKdt+S8r4eHYGHsDds=; b=s4ygXerzbDOW875HJWbm6LdilgKdKgpRWHstxI8BFh5jj2x7+2g0LteEF+KI2nZehd xggl70zTitRUooR12KVE56ONNbUKrWpIH1Z6Na1bj5E8MGQg0JkUn9BlLjvaojVevvnI 78JBXJD9EZ+utoxMlPSWtVL01BRHB8dK4ll1iSSFb4bxglpSzpBIIYjnhK5DJd3zVGoD vzPi+PBh5FDsNyq4e2qwMSdRjlMVmu0KTq6plGQL/7rcZJjaDxGanH88U2Y0XyO5qz7x /ipUC3HNjnB40KJj24+q3m8wN2JX/onEZLbhRFBpMrWtBLedLJTDXk77Lh747e94lGk8 H9Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sf1J73H9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e17-20020ac85dd1000000b003ef5ba0705bsi16587891qtx.802.2023.05.03.00.40.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 May 2023 00:40:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sf1J73H9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pu6pR-0008KL-3W; Wed, 03 May 2023 03:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pu6p1-0006vK-9y for qemu-devel@nongnu.org; Wed, 03 May 2023 03:22:43 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pu6ow-0007JI-Co for qemu-devel@nongnu.org; Wed, 03 May 2023 03:22:42 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f19afc4fbfso47555145e9.2 for ; Wed, 03 May 2023 00:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683098555; x=1685690555; 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=Hv/l59D9/l35x4T8g8G++KyGPDKdt+S8r4eHYGHsDds=; b=sf1J73H90MDz2ZWxg9lijB96cF2U3crrijjP3ziSQZQAK/ig3x/nPts3oNo7w+zowS YV8kdzmID4FN9h/nem13zpvtyflRaxIiQ5+UlzlXTeASeFc0FHpXR3kBn+A+pGfpOzt6 TBvKnZaUaJDQHNzKGAVLhGSf82jD4w0bDxKI7ndifEZJKo0mX37F7TqWwkrEtY9V2YU4 +lLqohklnoj8XbG6Xior5MfIMf7UKQX0BKZBUKknUrJHDFAFlZVb2UI61hGjncSsCvTq hRVn+TlvReJzyhNcnEd6jVv7062ajWQXBIIsotHf7QONCml0b4GHA1v0wtNCBOjJXWr9 W8EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683098555; x=1685690555; 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=Hv/l59D9/l35x4T8g8G++KyGPDKdt+S8r4eHYGHsDds=; b=Q2lKvdH/YYOI44TnszZlCqKTRclGUzw3oHpP6obMhJlX+0P/NOPO/TLvb0Oa5VLaq5 Dz6BNtnXP2rl3PTtlqI1cSdT5D/JT0d12xwRXropTOd85azZ1ZXRHkENoLtUITjPFmw4 luJJUQb5H2HFDxWjcvlDiVRXY3VA7fdyKSQND0KfKtsVxzI39m3PhxWMsXWvVJ+vmIgr S+nRcvjA8ao6oKYUxg1J7v4IYbI7kY4FdHEI8pfcoLV0csvA775CeD0dz0FRbrAfKYlL 00po9pWD6lbJ6wH+Z0zHyVHb3VBfPgodpHFEgTF8fjhVJtll99nQRK1mCyd8KODbkj3I DGXA== X-Gm-Message-State: AC+VfDxwtVowaN3eQRY09dI4VqD6vhnMCer/XrwW9sF/LIsNWfeY+m5l S+vPXMAYPlhlySuTWoWJo+gQR2GPJ81Y7ctiqnlfpA== X-Received: by 2002:a7b:cd18:0:b0:3f1:9525:7bb6 with SMTP id f24-20020a7bcd18000000b003f195257bb6mr13614382wmj.5.1683098554796; Wed, 03 May 2023 00:22:34 -0700 (PDT) Received: from stoup.Home ([2a02:c7c:74db:8d00:c01d:9d74:b630:9087]) by smtp.gmail.com with ESMTPSA id t4-20020a7bc3c4000000b003f1745c7df3sm962789wmj.23.2023.05.03.00.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 00:22:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: ale@rev.ng, philmd@linaro.org, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, anjo@rev.ng, Alistair Francis , Weiwei Li , Daniel Henrique Barboza Subject: [PULL v2 09/12] accel/tcg: Add cpu_ld*_code_mmu Date: Wed, 3 May 2023 08:21:02 +0100 Message-Id: <20230503072221.1746802-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230503072221.1746802-1-richard.henderson@linaro.org> References: <20230503072221.1746802-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x335.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org At least RISC-V has the need to be able to perform a read using execute permissions, outside of translation. Add helpers to facilitate this. Signed-off-by: Richard Henderson Acked-by: Alistair Francis Reviewed-by: Weiwei Li Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-9-richard.henderson@linaro.org> Message-Id: <20230412114333.118895-9-richard.henderson@linaro.org> --- include/exec/cpu_ldst.h | 9 +++++++ accel/tcg/cputlb.c | 48 ++++++++++++++++++++++++++++++++++ accel/tcg/user-exec.c | 58 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index 09b55cc0ee..c141f0394f 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -445,6 +445,15 @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx, # define cpu_stq_mmu cpu_stq_le_mmu #endif +uint8_t cpu_ldb_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra); +uint16_t cpu_ldw_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra); +uint32_t cpu_ldl_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra); +uint64_t cpu_ldq_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra); + uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr); uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr); uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index efa0cb67c9..c8bd642d0e 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -2773,3 +2773,51 @@ uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr) MemOpIdx oi = make_memop_idx(MO_TEUQ, cpu_mmu_index(env, true)); return full_ldq_code(env, addr, oi, 0); } + +uint8_t cpu_ldb_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t retaddr) +{ + return full_ldub_code(env, addr, oi, retaddr); +} + +uint16_t cpu_ldw_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t retaddr) +{ + MemOp mop = get_memop(oi); + int idx = get_mmuidx(oi); + uint16_t ret; + + ret = full_lduw_code(env, addr, make_memop_idx(MO_TEUW, idx), retaddr); + if ((mop & MO_BSWAP) != MO_TE) { + ret = bswap16(ret); + } + return ret; +} + +uint32_t cpu_ldl_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t retaddr) +{ + MemOp mop = get_memop(oi); + int idx = get_mmuidx(oi); + uint32_t ret; + + ret = full_ldl_code(env, addr, make_memop_idx(MO_TEUL, idx), retaddr); + if ((mop & MO_BSWAP) != MO_TE) { + ret = bswap32(ret); + } + return ret; +} + +uint64_t cpu_ldq_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t retaddr) +{ + MemOp mop = get_memop(oi); + int idx = get_mmuidx(oi); + uint64_t ret; + + ret = full_ldq_code(env, addr, make_memop_idx(MO_TEUQ, idx), retaddr); + if ((mop & MO_BSWAP) != MO_TE) { + ret = bswap64(ret); + } + return ret; +} diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index a7e0c3e2f4..fc597a010d 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -1219,6 +1219,64 @@ uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr ptr) return ret; } +uint8_t cpu_ldb_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra) +{ + void *haddr; + uint8_t ret; + + haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_INST_FETCH); + ret = ldub_p(haddr); + clear_helper_retaddr(); + return ret; +} + +uint16_t cpu_ldw_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra) +{ + void *haddr; + uint16_t ret; + + haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_INST_FETCH); + ret = lduw_p(haddr); + clear_helper_retaddr(); + if (get_memop(oi) & MO_BSWAP) { + ret = bswap16(ret); + } + return ret; +} + +uint32_t cpu_ldl_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra) +{ + void *haddr; + uint32_t ret; + + haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_INST_FETCH); + ret = ldl_p(haddr); + clear_helper_retaddr(); + if (get_memop(oi) & MO_BSWAP) { + ret = bswap32(ret); + } + return ret; +} + +uint64_t cpu_ldq_code_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra) +{ + void *haddr; + uint64_t ret; + + validate_memop(oi, MO_BEUQ); + haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD); + ret = ldq_p(haddr); + clear_helper_retaddr(); + if (get_memop(oi) & MO_BSWAP) { + ret = bswap64(ret); + } + return ret; +} + #include "ldst_common.c.inc" /*