From patchwork Tue Aug 22 07:13:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 715690 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp118531wrp; Tue, 22 Aug 2023 00:14:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHn9TvyT5dccMu6jpHzgQL+SzDBNDY8Gtw5nNFyRTKxHejOuvJlONG+MY6iDilpVUxJAaqI X-Received: by 2002:a05:622a:15c5:b0:410:7ba7:3820 with SMTP id d5-20020a05622a15c500b004107ba73820mr10627752qty.13.1692688488063; Tue, 22 Aug 2023 00:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692688488; cv=none; d=google.com; s=arc-20160816; b=n/GHJbbF9yvaEw3Poin90YHORJlCoE1fqgW2FRcuQsv1NtwGPQRdzNSosXeGT6S93t 7GT8/uTMznDi1Sd0PAfxyqdn+Jt81K0gbl4mWoQ8eop5r7ZecA9VlraZhShlZKuzqu/r WLhar4IQlOIYvXuD59qgw1x0IQNzzCv/SF8AaG3qhIbBvpH2lg7ueuq65+4aAPbFePvb wV/BpYfJCxF1VC7KRoQA4jzQ40/kD4qjdMDpDH3WfIi2goLrE13Y0p/vBUuxac3iMmsV WqmxZDkyHD7go9r3oYW5/870bVJbifXBx8HF6FfkjVFH+HbfnWTz3NUaPYr0r7eXL1t3 IcWw== 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=js7oG4DiRv1a4biKMcFP1KhLlrjkX0Ffo4ofKONC+vY=; fh=4esUdvAEMIazVUYz2fOQGDzgzc22eZT4lgTXTia56sI=; b=pRoc0Ox5yBzyBykbLUk5Xs0YdpiDxOTGX/zVVmeCOx999fvgxcSNZSaW97RdKLhga5 P6hNF9fdVahG6ByRhvzWneKty97zae68q8VG0WazSvXY7lEGzB0Q/09X/DIYM7SZvJBw 8Q69xNUmMukLGFhMj/zjDM+rugrxJOZaa3D0KYnykJbcYn0H/17DoTLO07+hgjtrVC+m B05NfSxgmE+bgGLH/v5MV9+Wl4rzUtSNqVHWrTKKmA1oTWttvlvQC8WVeGlY4QociK1o lXck6f0RgK6Tr4KSryh3xqYENIH1y8IsiZ8JyMIYqqzY5EoqQz1L9taaKqseFIpa5oCW MEew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IVyed04y; 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 p6-20020a05622a13c600b00403fe965af8si3445215qtk.33.2023.08.22.00.14.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Aug 2023 00:14:48 -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=IVyed04y; 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 1qYLan-0008Md-6R; Tue, 22 Aug 2023 03:14:21 -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 1qYLam-0008MV-0I for qemu-devel@nongnu.org; Tue, 22 Aug 2023 03:14:20 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYLai-0002pb-Jl for qemu-devel@nongnu.org; Tue, 22 Aug 2023 03:14:19 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31adc5c899fso3886373f8f.2 for ; Tue, 22 Aug 2023 00:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692688455; x=1693293255; 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=js7oG4DiRv1a4biKMcFP1KhLlrjkX0Ffo4ofKONC+vY=; b=IVyed04yOf53m/KTlRhA6/Mq0qXTxSpKsYKJ+1ffnhX8lPIjeMgXzrlkYHxgyBK4Su bqODQ0fDD6Vhjy3WPcFEK10iC4q727VsklbEdzCHdoKkhuMTO/rkilVuy7ueDAoN/MUT PcoPifHZv42/Otzx0PSom3hdGvTgtlijBV7hb28YMPdieKaOwZfCmsyQecibSrxb2YDu 2890Hb5Tw/eYCROdvzOpxec/Yhy3SX1YnY2AIcNMp6GkFzIpymNoYyCB6nHPV26khCrD C2HKP5duM/Gb4D0bTmtTQJj6yTb6nlusBnc5hVqTSSTEBrDep3n1oW9zhnDPayMDzVAi XYWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692688455; x=1693293255; 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=js7oG4DiRv1a4biKMcFP1KhLlrjkX0Ffo4ofKONC+vY=; b=B2YqeNv4SgkQKPAbiUtKdVv54tT8P6aGCyD6P+0UzEDackm79kgfHyZteq3OPsfve5 y4RPmpZBKIpKqaX8dCghgjprXYxdEMG3LhsI7+mzW4ncyNMVcZY0SvoDednvh21hOHv3 1rIURi0yF6u+gY7Gsqv5R1KwkrXiGXba3YyjvUY8/TONyYkciWB8CO6MAtlSr4hWjRr1 oQile9Gt0J28XE5I5W6ItazQEMipO7bC0PJCbWGiJqDrxnhJrdCbvRRRKtDFQo9AvFpR GZkSHRiM++e3mNUpsbCPafaNHkmv2RpzkZdFUQQE/iNuIy3RO8SXCx7Kk++v4AezatGo uoMw== X-Gm-Message-State: AOJu0YxJt4lgvLht8d8am6p2bDg+ydnuoP8zBQWyJPAU24D51md0gz7D 8dVWLvfIKXj0G1BB1LXtNfVvHthf1xVj81gj943GVw== X-Received: by 2002:a5d:5242:0:b0:317:5351:e428 with SMTP id k2-20020a5d5242000000b003175351e428mr6798342wrc.4.1692688454951; Tue, 22 Aug 2023 00:14:14 -0700 (PDT) Received: from localhost.localdomain ([37.19.214.4]) by smtp.gmail.com with ESMTPSA id c10-20020adffb4a000000b00317a29af4b2sm14740574wrs.68.2023.08.22.00.14.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Aug 2023 00:14:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Song Gao Cc: Xiaojuan Yang , Huacai Chen , Jiajie Chen , Richard Henderson Subject: [PATCH RESEND v5 01/19] target/loongarch: Support LoongArch32 TLB entry Date: Tue, 22 Aug 2023 09:13:47 +0200 Message-ID: <20230822071405.35386-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230822071405.35386-1-philmd@linaro.org> References: <20230822071405.35386-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Jiajie Chen The TLB entry of LA32 lacks NR, NX and RPLV and they are hardwired to zero in LoongArch32. Signed-off-by: Jiajie Chen Reviewed-by: Richard Henderson Signed-off-by: Song Gao Message-ID: <20230822032724.1353391-2-gaosong@loongson.cn> --- target/loongarch/cpu-csr.h | 9 +++++---- target/loongarch/tlb_helper.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/target/loongarch/cpu-csr.h b/target/loongarch/cpu-csr.h index f8f24032cb..48ed2e0632 100644 --- a/target/loongarch/cpu-csr.h +++ b/target/loongarch/cpu-csr.h @@ -66,10 +66,11 @@ FIELD(TLBENTRY, D, 1, 1) FIELD(TLBENTRY, PLV, 2, 2) FIELD(TLBENTRY, MAT, 4, 2) FIELD(TLBENTRY, G, 6, 1) -FIELD(TLBENTRY, PPN, 12, 36) -FIELD(TLBENTRY, NR, 61, 1) -FIELD(TLBENTRY, NX, 62, 1) -FIELD(TLBENTRY, RPLV, 63, 1) +FIELD(TLBENTRY_32, PPN, 8, 24) +FIELD(TLBENTRY_64, PPN, 12, 36) +FIELD(TLBENTRY_64, NR, 61, 1) +FIELD(TLBENTRY_64, NX, 62, 1) +FIELD(TLBENTRY_64, RPLV, 63, 1) #define LOONGARCH_CSR_ASID 0x18 /* Address space identifier */ FIELD(CSR_ASID, ASID, 0, 10) diff --git a/target/loongarch/tlb_helper.c b/target/loongarch/tlb_helper.c index 6e00190547..cef10e2257 100644 --- a/target/loongarch/tlb_helper.c +++ b/target/loongarch/tlb_helper.c @@ -48,10 +48,17 @@ static int loongarch_map_tlb_entry(CPULoongArchState *env, hwaddr *physical, tlb_v = FIELD_EX64(tlb_entry, TLBENTRY, V); tlb_d = FIELD_EX64(tlb_entry, TLBENTRY, D); tlb_plv = FIELD_EX64(tlb_entry, TLBENTRY, PLV); - tlb_ppn = FIELD_EX64(tlb_entry, TLBENTRY, PPN); - tlb_nx = FIELD_EX64(tlb_entry, TLBENTRY, NX); - tlb_nr = FIELD_EX64(tlb_entry, TLBENTRY, NR); - tlb_rplv = FIELD_EX64(tlb_entry, TLBENTRY, RPLV); + if (is_la64(env)) { + tlb_ppn = FIELD_EX64(tlb_entry, TLBENTRY_64, PPN); + tlb_nx = FIELD_EX64(tlb_entry, TLBENTRY_64, NX); + tlb_nr = FIELD_EX64(tlb_entry, TLBENTRY_64, NR); + tlb_rplv = FIELD_EX64(tlb_entry, TLBENTRY_64, RPLV); + } else { + tlb_ppn = FIELD_EX64(tlb_entry, TLBENTRY_32, PPN); + tlb_nx = 0; + tlb_nr = 0; + tlb_rplv = 0; + } /* Check access rights */ if (!tlb_v) { @@ -79,7 +86,7 @@ static int loongarch_map_tlb_entry(CPULoongArchState *env, hwaddr *physical, * tlb_entry contains ppn[47:12] while 16KiB ppn is [47:15] * need adjust. */ - *physical = (tlb_ppn << R_TLBENTRY_PPN_SHIFT) | + *physical = (tlb_ppn << R_TLBENTRY_64_PPN_SHIFT) | (address & MAKE_64BIT_MASK(0, tlb_ps)); *prot = PAGE_READ; if (tlb_d) {