From patchwork Tue Aug 22 07:09:54 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: 715680 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp117354wrp; Tue, 22 Aug 2023 00:10:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEd8dvGL9zboXLZ1L+smZzTQRyhy62ThcMgzLg1vTa3A+GuSC4xvwWZNcIqfAAax5QwLZnk X-Received: by 2002:a05:620a:4493:b0:76d:9b13:a2f3 with SMTP id x19-20020a05620a449300b0076d9b13a2f3mr11160130qkp.13.1692688253525; Tue, 22 Aug 2023 00:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692688253; cv=none; d=google.com; s=arc-20160816; b=neMDkHOysQBw2NC9a41bGOvww+4Oj7DAKrbM19W1GZjep0fkHH+27BzlzlgY0U07wd MlnuP/aZvnPtBAYNuTMysdWRkX1CRf1xjRJhSl/XPTrATccVMlyetIngtCg/mxnjF4k5 Fi4jWVUns0ETyOk102bfh5QEwH71hsLKxIa14TxvDARn1o3OSlRAl6w+vwesxAk6oNyf f7Z0tBpvMzxksCFginPkUv0GLpdntrcDo9ua4lymmmk80PgYprz4t7x2mlVjyeWRYdCT pzPp8q4phs075nZsXv02YrhwjMgHmqo9FJ3q3ao2eZYVNdhoi18uP66djrFuJrSuPVqm oUPw== 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=ll8wP0pkdoX0Mi1LmYRa/p8XYYNe59YpqNAwTi/SoQ4=; b=iomFAwgqHUSA2OMe6KnJ1yQkb+I7JkkNzTDfDw/VNCW6HRiDh6D+X2J36RijBt6/MS arcrfK2yj2KK1/j8+GG7DaZEqkMY+Lz+kEK9eqkdFiAl370A6p7EmE2Ow6PkPkjwZKsQ uBl5iWFxwrEKN68d4fGNrBL2HgdcxV7SbJ/M/eWDnoKKg6AEJ5ImLyFQumEi+hBKU3Iy 0Tb+WdEGHEQ1bfZKhKSBjfiJzq2rkoJr9C8JkUWGVR2IxtL7Z2CCNd9GCK3uvRnJDr0c y0T9Mqkxe7BCbw8P07811QxxQWM2HNi/lrlUFfFzXqeY0SxwG5jkl0AqXfYT3ON8k9nh y6cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LjnsYBOM; 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 q1-20020a05620a0d8100b007682f9ca13fsi5752022qkl.608.2023.08.22.00.10.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Aug 2023 00:10:53 -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=LjnsYBOM; 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 1qYLX6-0002A9-OU; Tue, 22 Aug 2023 03:10:32 -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 1qYLX2-00029l-J4 for qemu-devel@nongnu.org; Tue, 22 Aug 2023 03:10:28 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYLWz-0001xM-9Z for qemu-devel@nongnu.org; Tue, 22 Aug 2023 03:10:28 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fef3c3277bso12895415e9.1 for ; Tue, 22 Aug 2023 00:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692688223; x=1693293023; 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=LjnsYBOMiD85mxT9wIojt2PRG2gfGgg0kDhaSIFe2lSZ864NGCiqmXy75QbLpJ/kjS TNheR0/2UlpygiFSRiu+aEHg4Bzb1TQBhCCHgrfhcfiHWyfSz/dInQ0YoBwVky0+VHeT Vc5qcqZw3DSvTGfH1j6yMe1RPpJd2HusuMrCPpbIEBV1THQW4Yhswy++I7+Lls6MWHzk mvBzG3GHOUlngF1rN3Wnd4GBLDVeBDF9FrzZhz5UAxF6sPWoz46X4g1MvrlpcZ5lRQvH yo4G//w/F2T3sYZu3tfcXbT5QYkbGjMJZmy4/46w2AgTZNqnFsZ8bx0VEXW2RnKj9rtK YPWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692688223; x=1693293023; 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=EsNHivSiEIORkVvR4a8pnIgJB0Zh6ink1uEOMg2ApsbOSEbXB4cyhADdZcqnsI02uI pO/KdD6ZONXwGSJ0VlgqYSP77mOnd6q4xJbpl2ZQaBP6OVdMJ4TXeEVzyTrN2xaQxiza CKXgmLhL/Tbd0IH3arsvWr9cD0bH4BgMIxvafzz4rkCNkw0/oLJc1bqUV2DLOhdGS1vI IHtTbCIh/X3lDc0VpwZCZcix3LfZhc1lfyHT8v/U1qWBzSl9g/ZL/j6wfhncmKwaNg3c 5Q/Ccmt/jsSdw9kg5o9RFu2ORQH/lI2R+k62/NsbovSwnlX/rUOxrA7Z40Rvd4lCzQy7 6Y+w== X-Gm-Message-State: AOJu0YwoLuYePCHAA7ufUtv/EtNhW9rddak1ot1e+IpD4QW9LuXx7ilB dHU9evFrvKQ4HRkWJzMWNpni1+Bd2fheEwSxPyN/eg== X-Received: by 2002:a7b:c4c9:0:b0:3fe:2b8c:9f0b with SMTP id g9-20020a7bc4c9000000b003fe2b8c9f0bmr6543968wmk.23.1692688223599; Tue, 22 Aug 2023 00:10:23 -0700 (PDT) Received: from localhost.localdomain ([37.19.214.4]) by smtp.gmail.com with ESMTPSA id u1-20020a7bcb01000000b003fefcbe7fa8sm40904wmj.28.2023.08.22.00.10.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Aug 2023 00:10:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Song Gao Cc: Huacai Chen , Jiajie Chen , Xiaojuan Yang , Richard Henderson Subject: [PATCH v5 01/19] target/loongarch: Support LoongArch32 TLB entry Date: Tue, 22 Aug 2023 09:09:54 +0200 Message-ID: <20230822071013.34884-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230822071013.34884-1-philmd@linaro.org> References: <20230822071013.34884-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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) {