From patchwork Fri Feb 2 05:49:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769146 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp753929wrc; Thu, 1 Feb 2024 21:53:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGYS4MLP8KMNHs+P9/cwO+ZWsFhbBFbgxvsMNvgnacoZCa14ug5kxTW48kC8F5bYyMvVIt X-Received: by 2002:a05:6214:2266:b0:686:aa78:df4d with SMTP id gs6-20020a056214226600b00686aa78df4dmr1280368qvb.53.1706853197529; Thu, 01 Feb 2024 21:53:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706853197; cv=none; d=google.com; s=arc-20160816; b=bLj6hwDzmSTg1Sh/zI+zGBRbOOBmvNJphNrp17lb9jH3gFgoiudMi3nHeLjXu5Agya 9aNG1pgPYUgDXc2pM77Z62ooK1c9KvXVOCB3oytN1J/K+WsdbcmqUkzlMOJJL1PZ72Cm Z69pQ6cNIyuqXsQXfT8jeSW8cenZ2/E1BOcNNNoSIQIzLE+n8VoVLGt6XGLGr9clQ4/s 0d2ZFznYCB/aaQEVwop7BIw/2Ph1Y6DSere8K3MZP2sQD+UUr4fT7XSf1dcbef2wr2Cm DUjf69kLDov0UQH8Mps00gtA1zqvh/fIdYxBahV1eG3n7Xaib49+RRye/TjRS2bcrW0G TmSg== 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=VAmZNL9zYMPpuAsM9Gmw83HdlClN4X7nwCS0CqUYsPQ=; fh=TlZOkldLVe59vxeKm6eMGbMziOHgTimTudEApGzQD/w=; b=hnjINsqbdIkn1WtDisJEWD1jnITtNkhyPo0xaEYt/VLi2QhrZLo4Y0Xz1qLn9puXKR ve+hc3usqHd52aZfjR0nJ5X9J+vBLP+Wbd25eTZLyL/Ie6ArLY6BtkGspSeZBYFHNB+K LdyM6f4drCentnIhqrqzdDPksO8bgr1jL5mvUY/2WK20FxZGfT2dmmapuL3yzse/b7Ym ymnN40ajdkWTzlIDWF7MCmlBx2ulZROp2cJn4dcI8igLJwXl8vgBh6FGO3X0BNubJrHs /G4Q2okc+Wf/a1LokhnXz+qRWdQFK6oVWMDax/uPJ4veP7YJhVboqSCIMlXk8e+v7UMV W2nA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JZPzlnof; 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 X-Forwarded-Encrypted: i=0; AJvYcCXK0eg0gEzF22zaYp7oRU+nILkrbXYp/OKbs+HzJpjsswiA7aSM+3QylpYi8/cvhyNDLYPZ+34VVlOhbjFGQEfP Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id el3-20020ad459c3000000b006819712c52asi1195740qvb.474.2024.02.01.21.53.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Feb 2024 21:53:17 -0800 (PST) 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=JZPzlnof; 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 1rVmSF-0001D4-Ji; Fri, 02 Feb 2024 00:51: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 1rVmSD-0001CX-MZ for qemu-devel@nongnu.org; Fri, 02 Feb 2024 00:51:09 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVmSC-0001hk-5r for qemu-devel@nongnu.org; Fri, 02 Feb 2024 00:51:09 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6dfefb490f9so730885b3a.1 for ; Thu, 01 Feb 2024 21:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706853065; x=1707457865; 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=VAmZNL9zYMPpuAsM9Gmw83HdlClN4X7nwCS0CqUYsPQ=; b=JZPzlnof9jffflidWcVsmyiFpmOrDvm/aKSfoKMJCeM1U40HsDngqWGTe6oqndNNhK 65jVsINj6jgm7PST6Q4Mw7eCVrf0MIpm3iMZQeM2kHGNlIpENAWYMT9R4xJbKdfHuZfR NWmNzYvHj209Ahxx5GFFpC6u4nCTQeG/1JYLNmvV8CshUF5b3866qdplLemKOaS+OMSD zU2jj0qGBxHp8PAJxK0SU9tse4VSUKIJbmXweKs8uFluWVtn9G68kn89BTNz6uU34zei xaSrcbS4mQ912RA4pA9+d0+H2E7jUidUP7fcN3P67uCR053DvMIGvhdPnbEcZQCNuF4T PpKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706853065; x=1707457865; 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=VAmZNL9zYMPpuAsM9Gmw83HdlClN4X7nwCS0CqUYsPQ=; b=euQe/EDYjEClvkh7Hkv1EA10cuDJNhGqnP22y8O51UGFM9hzTikXMj4fpy3i1LJe+j 7pxijQKADsb18Ha5O3Yfq+eVKg3opTnOg/mHgaNxGnJQKKIjAzpwowaHvPmXb2MsdyMf mmqsfsBjJEaqVJF8Ky1M3cgL9OW+vZXomzVQs3OrJBO/CemHSsDd+hMP+J1G0tH+Hl2B iZWvk5hm62GuAWvP3BmsTyxtemYzpnlRKV1/lI2Z1tlVe7NFeRlSz7AnZ/Ru499ekqrN d+Aw/+zFyWb9EhQOWxqd0P1Stg73Oe1tEowA6XmUDSjTWh7YQy1ffGp8mqZoSzLn9tos Akog== X-Gm-Message-State: AOJu0YyegxtTW8fe+X/JIRxE9LMWRp/qMnDB8uqhDLW4oXZ98WAWQg7J SK8xuY+CFMmYXgXdm5Chmpz/iRGYvVSYeWo/j6kX2xhzl75PcvYSKjhoeKipJNtG6vg1UXmv1vT LJOQ= X-Received: by 2002:aa7:810e:0:b0:6dd:a086:1e0f with SMTP id b14-20020aa7810e000000b006dda0861e0fmr1208361pfi.32.1706853065709; Thu, 01 Feb 2024 21:51:05 -0800 (PST) Received: from stoup.. ([103.210.27.218]) by smtp.gmail.com with ESMTPSA id h2-20020aa79f42000000b006dab0d72cd0sm715111pfr.214.2024.02.01.21.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 21:51:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 11/57] target/loongarch: Populate CPUClass.mmu_index Date: Fri, 2 Feb 2024 15:49:50 +1000 Message-Id: <20240202055036.684176-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240202055036.684176-1-richard.henderson@linaro.org> References: <20240202055036.684176-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/loongarch/cpu.h | 6 ++---- target/loongarch/cpu.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index 0fa5e0ca93..5dfcfeb3a4 100644 --- a/target/loongarch/cpu.h +++ b/target/loongarch/cpu.h @@ -408,15 +408,13 @@ struct LoongArchCPUClass { #define MMU_IDX_USER MMU_PLV_USER #define MMU_IDX_DA 4 +int loongarch_cpu_mmu_index(CPUState *cs, bool ifetch); static inline int cpu_mmu_index(CPULoongArchState *env, bool ifetch) { #ifdef CONFIG_USER_ONLY return MMU_IDX_USER; #else - if (FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PG)) { - return FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PLV); - } - return MMU_IDX_DA; + return loongarch_cpu_mmu_index(env_cpu(env), ifetch); #endif } diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index fb8dde7def..cbecc63213 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -375,6 +375,16 @@ static bool loongarch_cpu_has_work(CPUState *cs) #endif } +int loongarch_cpu_mmu_index(CPUState *cs, bool ifetch) +{ + CPULoongArchState *env = cpu_env(cs); + + if (FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PG)) { + return FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PLV); + } + return MMU_IDX_DA; +} + static void loongarch_la464_initfn(Object *obj) { LoongArchCPU *cpu = LOONGARCH_CPU(obj); @@ -779,6 +789,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = loongarch_cpu_class_by_name; cc->has_work = loongarch_cpu_has_work; + cc->mmu_index = loongarch_cpu_mmu_index; cc->dump_state = loongarch_cpu_dump_state; cc->set_pc = loongarch_cpu_set_pc; cc->get_pc = loongarch_cpu_get_pc;