From patchwork Tue Aug 13 10:18:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 818818 Delivered-To: patch@linaro.org Received: by 2002:adf:cd01:0:b0:367:895a:4699 with SMTP id w1csp202035wrm; Tue, 13 Aug 2024 03:19:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV7ND5ZuouD+IoZJqaSKZRlIWIl3WRWzF/BCCGMMljb6ah+oXEe3jwKcmu9oJTamNncUhmbexBOv/FdUWi4H/XM X-Google-Smtp-Source: AGHT+IH8bGgqtPwQgqOy4i0D21PZlIBnY3pvjqaQ4IxtUrehfBDXB2DGWnS5a5KX/8NXaOVxp9dL X-Received: by 2002:a05:620a:4043:b0:79f:515:e211 with SMTP id af79cd13be357-7a4e15bdc69mr375372885a.46.1723544399260; Tue, 13 Aug 2024 03:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723544399; cv=none; d=google.com; s=arc-20160816; b=N6zTsJ5bddR3+dWDnvz+0rtWhc4BledpeLc1KYmHKINigL/ujjxudyuKvBh1VCCr5/ hu0GfVMKCTUK4u5UFYXqbKtWtpdz8tELu+LtPqpcgI8yhK9laOOdkOffvWY3dIOk3uSl cQZ769pKfjYTF7Cbop+LtkzHX6fh02sXOO4ptNohyxBlnsuVb9R8ftAT4Xpv5LXWLq9Z 3axeBJOE/PbUL5xQDZthSWK3Hwq1Xt8FSlv8iOuH9I0n6wY7DqBzE0KxR7VTHAHJaPq/ bsHAPXcID1/lr9EjrAgcywqNul9/MVAI5gNSSQ7R4dWKZPyD5fr3LoR0PQCiFJurOjXg kaNA== 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=lA8uJXpJ/5fYFYlheHCIQUkasDjz5vKdapmYLx+X7e0=; fh=YVqZlH20Ag/1MZCJ6hgjo6Qu1yStWaLy01q6vclOBVI=; b=cQMZrpZ+9Cn3vV4MWhaicjU1QHJacLzaEhIhE7f+/3CDkQHL7w1SLGYW1zFNXn8jwY p6DxlAIWEK4eX97jDO5rD4HG2EDnkmmXb0snBTO+cKtgujP5Q0e+zc29OMWvWdtO67os 7LQsMjlZ5bXOVVTyMYMRP9g1Ej7VmuLSNmbDTT5oqBd3MOY6MROVW8/lfT4oC3qkV+I2 Unamyu4b1nmdK0X7n1jaFt9sruolJvzitxV4+1ByjfJvufZ3L9c0iYtFjTo6CN9zvk4f glZRZEITQIcDDTMa+yDSdl3IsHEZmQGG9VTlk6la7RCDo39O6+cYbJ4vB+Z/MHMVkM8s mjNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U0TmQD0z; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a4c7d71212si797188885a.174.2024.08.13.03.19.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2024 03:19:59 -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=U0TmQD0z; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdoch-0006Uf-6y; Tue, 13 Aug 2024 06:19:27 -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 1sdocf-0006U7-IP for qemu-devel@nongnu.org; Tue, 13 Aug 2024 06:19:25 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdocd-0005oJ-N5 for qemu-devel@nongnu.org; Tue, 13 Aug 2024 06:19:25 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2f0dfdc9e16so63370511fa.2 for ; Tue, 13 Aug 2024 03:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723544362; x=1724149162; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lA8uJXpJ/5fYFYlheHCIQUkasDjz5vKdapmYLx+X7e0=; b=U0TmQD0zaW4fVqXRZtYi+r/oabh2OV+nGnpxGZaoDP+2zUcqlyEIRG3lPNL9MKHteM mL0QhEypGsvlxENdwvTJlJmM9lG7IxORnoyBAaqJ0Dw3AjLp/zfyhSsWzfQgcXzc6pDD cWjf1IvM+FOR0d5l2SiJyar6PvlqkLBdZgC0kq5RG/WkFvvhSSOsamu6fglVCcYBUFz1 Z9rdtr7skUr0KDmmHtKJ/+H9KhKAbBxa9ksMinlQLmNLa7MMek2t5hj9jsSDWM83X8fL zJMRXDHtyJoyuBgcuZgFEyVrDqNflP8Ms2BkgT54GKM/7ZfG6ogT/Oma98HmeBz4YRgZ APTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723544362; x=1724149162; 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=lA8uJXpJ/5fYFYlheHCIQUkasDjz5vKdapmYLx+X7e0=; b=AkVnJvE+gHIL6ZdsF7Ykh9BqFaeZUo2KBA0fP2uF5oB2PA2tcOUClifySQwV3JJsV7 JJXqGXbj+lBW408j6Eu3pDT0ET4Z0Ob3dwi2GBsBmD9QMDlFB50fbzuxmC8DHi3wZPKP yQCrTNZL+neuLSkX4iSypNiYJox8Xnp67Y5IMXzueotXJRNVUi/QFGy5MEurYmfT83HR lS3SmizsVyjtGu48fOppnVS/goa0ibgW3zlhp25Qnbib5TFlgbCHgcI2lSivNyLXkpc9 jmkFindTN03QVhyzQ//IU1Mv9N25Fb9vdB7Eu+jprDd+ZXBJDS380VIVBOoCSA4SwYHe 8OVQ== X-Gm-Message-State: AOJu0YwmNAcw03QrBxfS1ZeQSLnVeEn5yfJ1k5H0bUs80nJePHFGFm/H AnflZaC6mgLUfa5jNYwXQOUU0qemBJPpuS3hs8OrIZOO9nZp6uvzbTFhgANMrrEeIPa0pGJ80/S XecE= X-Received: by 2002:a2e:a7ca:0:b0:2ee:8453:5164 with SMTP id 38308e7fff4ca-2f2b70cb3c9mr24176611fa.0.1723544361515; Tue, 13 Aug 2024 03:19:21 -0700 (PDT) Received: from m1x-phil.lan ([176.176.129.17]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bd196a7a11sm2852621a12.53.2024.08.13.03.19.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 13 Aug 2024 03:19:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Aurelien Jarno , Thomas Petazzoni , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Richard Henderson , Aleksandar Rikalo , Jiaxun Yang , Waldemar Brodkorb Subject: [PATCH-for-9.1 v2 1/2] target/mips: Pass page table entry size in bytes to get_pte() Date: Tue, 13 Aug 2024 12:18:55 +0200 Message-ID: <20240813101856.49469-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240813101856.49469-1-philmd@linaro.org> References: <20240813101856.49469-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.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 In order to simplify a bit, pass the PTE size in bytes rather than bits. Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/sysemu/tlb_helper.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_helper.c index 3ba6d369a6..a8caf3ade8 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -592,13 +592,13 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, * resulting in a TLB or XTLB Refill exception. */ -static bool get_pte(CPUMIPSState *env, uint64_t vaddr, int entry_size, +static bool get_pte(CPUMIPSState *env, uint64_t vaddr, unsigned entry_bytes, uint64_t *pte) { - if ((vaddr & ((entry_size >> 3) - 1)) != 0) { + if ((vaddr & (entry_bytes - 1)) != 0) { return false; } - if (entry_size == 64) { + if (entry_bytes == 8) { *pte = cpu_ldq_code(env, vaddr); } else { *pte = cpu_ldl_code(env, vaddr); @@ -607,11 +607,11 @@ static bool get_pte(CPUMIPSState *env, uint64_t vaddr, int entry_size, } static uint64_t get_tlb_entry_layout(CPUMIPSState *env, uint64_t entry, - int entry_size, int ptei) + unsigned entry_bytes, int ptei) { uint64_t result = entry; uint64_t rixi; - if (ptei > entry_size) { + if (ptei > entry_bytes >> 3) { ptei -= 32; } result >>= (ptei - 2); @@ -630,8 +630,8 @@ static int walk_directory(CPUMIPSState *env, uint64_t *vaddr, int psn = (env->CP0_PWCtl >> CP0PC_PSN) & 0x3F; int hugepg = (env->CP0_PWCtl >> CP0PC_HUGEPG) & 0x1; int pf_ptew = (env->CP0_PWField >> CP0PF_PTEW) & 0x3F; - uint32_t direntry_size = 1 << (directory_shift + 3); - uint32_t leafentry_size = 1 << (leaf_shift + 3); + uint32_t direntry_size = 1 << directory_shift; + uint32_t leafentry_size = 1 << leaf_shift; uint64_t entry; uint64_t paddr; int prot; @@ -768,7 +768,7 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, ptoffset0 = (ptindex >> 1) << (leaf_shift + 1); ptoffset1 = ptoffset0 | (1 << (leaf_shift)); - leafentry_size = 1 << (leaf_shift + 3); + leafentry_size = 1 << leaf_shift; /* Global Directory */ if (gdw > 0) { From patchwork Tue Aug 13 10:18:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 818819 Delivered-To: patch@linaro.org Received: by 2002:adf:cd01:0:b0:367:895a:4699 with SMTP id w1csp202138wrm; Tue, 13 Aug 2024 03:20:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUTvBLGmT2GP9hxpZfSUwuo/UbaJmXrkADHR6/OMtVyL4q58mTdJZjV1rMI6iJ1WKwcx6+AsIaHwPkJ18ei7Yc4 X-Google-Smtp-Source: AGHT+IEOdS6EkKuFplWb3x1Hyw7gXTzQg30rR7O4+2WQ+Kcx3Vs1OlOQkgODlfZ1bi50FIEi2T7I X-Received: by 2002:a05:6214:5911:b0:6bb:7bed:6fae with SMTP id 6a1803df08f44-6bf4f8310afmr53381106d6.43.1723544419948; Tue, 13 Aug 2024 03:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723544419; cv=none; d=google.com; s=arc-20160816; b=Jk6ulblxgV588ZNxYHRKJDVpu8HMkpCNbODMgQNjAnJWdfbzh3Kbjg2TyPp2KIrYS3 zzLap8wPi+HIBOcxd5SLQFjNgDFToYWV607yPZ+tb5SgwUEqYRpW2dgH0UHMlPBEsDOy Pglenu+Ki3ywGzey/l8/7nFGz7VfFoPJrbkO9A94HKlSRkkH7onjT/z47EQG3DVMp6D8 r526lQHWqOU1GpsMs8Zg6yNsewwp6zIXwRjgqLe7I2TmLYHNWeZU7JBIbxNLFQ8i10lU GWr0ODkSBYZK98WglM8DsxIfRMO/29lDduRiCdUhvAegzi+XwgIyN5B74Dz5V+3hBHq5 gDtA== 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=FQjGZK3beew7IwbGeEw9H3Yr18ElnIBqbghrqrG+68k=; fh=YVqZlH20Ag/1MZCJ6hgjo6Qu1yStWaLy01q6vclOBVI=; b=PqtgxxJgyU7w+sdqTDQOJO5crDPmmvPoTfk+vq7+JCWej9IE0jYUkaHO09oInnCZFg hK+d/602vxFgvZ5AoazbUNkTFJW1ZZ1C+LcOrzG9LmaQvoaKvvKNtc37nrcEJ5qlD0lB uxf4GhAiRM0GA/s91IjtiNHTzwa+IiLviYdib52iE2qKNDVbWf7IMLFZpOx7FYtsjZhM UJxPcozuxTB7sPjdiphVRe1vv+XiLMIpEUetrO9axYKwv0HnYYSmarbO3w3mXrFUpVtK nC6bsf07KF8UqSfnAFZfrtPqFYLM/CxIb7Q40x7lwFyF7AobasTbwFOTQn3nGMbUV2vX q4hA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NOBymis3; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6bd82c607f2si80602626d6.19.2024.08.13.03.20.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2024 03:20:19 -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=NOBymis3; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdodF-0008G7-4N; Tue, 13 Aug 2024 06:20:01 -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 1sdodB-0007mq-DL for qemu-devel@nongnu.org; Tue, 13 Aug 2024 06:19:58 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdod8-0005qL-CB for qemu-devel@nongnu.org; Tue, 13 Aug 2024 06:19:56 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5a156557029so6027215a12.2 for ; Tue, 13 Aug 2024 03:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723544392; x=1724149192; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FQjGZK3beew7IwbGeEw9H3Yr18ElnIBqbghrqrG+68k=; b=NOBymis3qSyv5eBA4i1pixFJfjxpm/fV6/eCzuJccvOFECsmPZUQ6Jt9Fl2QVANMap lat76to18POYabB4lGlm8RjVCS6rIEeSSZDIlr3QcO6TZJkdE7iFK2oK+96mkO7O30jP kUbwriwEN2iIH6HkRlUHci6T4vFhGZW5gpTVszhcEVOkQ06XtPWiVa3sGvuCnmsuYv9D ACP2TL1ZLtP9vl/xwfGtb4Maw89u1DtJvYAkvQu2E/Hw+HxiyH/Raa0olMsqtvbNk7f5 uHquqCLc7pIiMNuxkfB4YYN0ryOeORGGNe0eUDlHwsWCT66vA37p0L8tdrWWMcLqfI/7 XKOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723544392; x=1724149192; 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=FQjGZK3beew7IwbGeEw9H3Yr18ElnIBqbghrqrG+68k=; b=aHhes0SavJlWUBRJn4VmfRq81j6rX15vQ4zJ57tQZB5Wab/vWSedVywwTucTNgEhfA aYxAFp7UMGogo9Psk9ObAljIp8RzKRmxLqcFyHoPTMOR/eZlOW/x2TEq1QAVbxQujRp5 ZG5SWMYkYOQwx/Ncn8GeaKUJ8AMowFVq5/RDqAWx25ZNuKV1pAeS6gODQCH8F159z9IV oFyRxJ4nzZwz19FUG6O1VMEozY0aY3C+RBKNhHk5/UZFNeJjsP6Woj3zwXr56HbFZ5+V QmCd6YRk5MLic+mPgPU5XNlxd2CcGVVPrYnnxxrpZyhQltH+GPLmhxLnmDoggad0Z0Uz WhjQ== X-Gm-Message-State: AOJu0YxM0D7CBEd4JRZvCFX+FRk7E8VzPax6H+EgIVsZMs8ZkBbrQiOB zmDw9Yjlka011aHQxEba1lDegYRqQit46DEOiDKZNlR3d7O/zNqKGsax+2mjon5/cPKpzBvE9mO ZEaw= X-Received: by 2002:a05:6402:270b:b0:5a2:8802:8e10 with SMTP id 4fb4d7f45d1cf-5bd44c0feb3mr2279145a12.8.1723544392161; Tue, 13 Aug 2024 03:19:52 -0700 (PDT) Received: from m1x-phil.lan ([176.176.129.17]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bd191a20fcsm3046548a12.36.2024.08.13.03.19.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 13 Aug 2024 03:19:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Aurelien Jarno , Thomas Petazzoni , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Richard Henderson , Aleksandar Rikalo , Jiaxun Yang , Waldemar Brodkorb Subject: [PATCH-for-9.1 v2 2/2] target/mips: Use correct MMU index in get_pte() Date: Tue, 13 Aug 2024 12:18:56 +0200 Message-ID: <20240813101856.49469-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240813101856.49469-1-philmd@linaro.org> References: <20240813101856.49469-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=philmd@linaro.org; helo=mail-ed1-x530.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 When refactoring page_table_walk_refill() in commit 4e999bf419 we missed the indirect call to cpu_mmu_index() in get_pte(): page_table_walk_refill() -> get_pte() -> cpu_ld[lq]_code() -> cpu_mmu_index() Since we don't mask anymore the modes in hflags, cpu_mmu_index() can return UM or SM, while we only expect KM or ERL. Fix by propagating ptw_mmu_idx to get_pte(), and use the cpu_ld/st_code_mmu() API with the correct MemOpIdx. Reported-by: Thomas Petazzoni Reported-by: Waldemar Brodkorb Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2470 Fixes: 4e999bf419 ("target/mips: Pass ptw_mmu_idx down from mips_cpu_tlb_fill") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/mips/tcg/sysemu/tlb_helper.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_helper.c index a8caf3ade8..4e64c226a5 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -593,16 +593,21 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, */ static bool get_pte(CPUMIPSState *env, uint64_t vaddr, unsigned entry_bytes, - uint64_t *pte) + uint64_t *pte, unsigned ptw_mmu_idx) { + MemOpIdx oi; + if ((vaddr & (entry_bytes - 1)) != 0) { return false; } + + oi = make_memop_idx(size_memop(entry_bytes) | MO_TE, ptw_mmu_idx); if (entry_bytes == 8) { - *pte = cpu_ldq_code(env, vaddr); + *pte = cpu_ldq_code_mmu(env, vaddr, oi, 0); } else { - *pte = cpu_ldl_code(env, vaddr); + *pte = cpu_ldl_code_mmu(env, vaddr, oi, 0); } + return true; } @@ -643,7 +648,7 @@ static int walk_directory(CPUMIPSState *env, uint64_t *vaddr, /* wrong base address */ return 0; } - if (!get_pte(env, *vaddr, direntry_size, &entry)) { + if (!get_pte(env, *vaddr, direntry_size, &entry, ptw_mmu_idx)) { return 0; } @@ -669,7 +674,7 @@ static int walk_directory(CPUMIPSState *env, uint64_t *vaddr, ptw_mmu_idx) != TLBRET_MATCH) { return 0; } - if (!get_pte(env, vaddr2, leafentry_size, &entry)) { + if (!get_pte(env, vaddr2, leafentry_size, &entry, ptw_mmu_idx)) { return 0; } entry = get_tlb_entry_layout(env, entry, leafentry_size, pf_ptew); @@ -827,7 +832,7 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, ptw_mmu_idx) != TLBRET_MATCH) { return false; } - if (!get_pte(env, vaddr, leafentry_size, &dir_entry)) { + if (!get_pte(env, vaddr, leafentry_size, &dir_entry, ptw_mmu_idx)) { return false; } dir_entry = get_tlb_entry_layout(env, dir_entry, leafentry_size, pf_ptew); @@ -839,7 +844,7 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, ptw_mmu_idx) != TLBRET_MATCH) { return false; } - if (!get_pte(env, vaddr, leafentry_size, &dir_entry)) { + if (!get_pte(env, vaddr, leafentry_size, &dir_entry, ptw_mmu_idx)) { return false; } dir_entry = get_tlb_entry_layout(env, dir_entry, leafentry_size, pf_ptew);