From patchwork Wed Apr 12 11:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 672624 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp288505wrx; Wed, 12 Apr 2023 04:47:35 -0700 (PDT) X-Google-Smtp-Source: AKy350bhPUwmlRJZ+K1Ye3FUhe4KWOWzHv5CgeKPxAK2c+Pi760RxJEwpCPsK/B65tL6FwVYUqPw X-Received: by 2002:a05:622a:a:b0:3e3:93ca:42c8 with SMTP id x10-20020a05622a000a00b003e393ca42c8mr29360842qtw.67.1681300055069; Wed, 12 Apr 2023 04:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681300055; cv=none; d=google.com; s=arc-20160816; b=nh8gwhva6Cdgp+wEpfjE5bWQn2IozM2IqLMQjuYMaCUgp2k0M/o5PZQedYOVMNMfMW 8wN+UZyZ8B/xabCR45ugtn434XKaeixan7N3byVDEBN9/UTu9CEsGeqaSNRW2JaAUVkj T/Ht1OfeiDQCvNFOH/155Qs+VCPMiKow/nxKogg3zF02yShTQ6AL3X/kL4RWm+cIIW+B 3oZepxuQggSGFs5r+NKJcE5tTpRVFzQrKV5LovOSQJSNJLRxsUNLwYLX6k884Ih+/Wpq 5Lhzkzd1bC3azle6tXxSyNcq3TzeSeSpenzgXPSD04bYPQir3Z70vKZC89snRMwXLo70 hZmw== 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=sZWSjtdLuqRfAHXhQ1Qn/4gxDZYp/Ml73FoJP/ry5BM=; b=lqejp7y6GnM3mbTsdvkrsuTUPWlKo8aJnsNOscj31taFG292WHBK7y+pNhGjKPLGOI dZRcUSuyoNm3Ye3R7FkpXswOP/5paHq8p18dKyoHGPLuZ5jNJwx4PLPKf2gS/Lb5hY77 jlfWNrSk7+yolxAPMdlHNnyT8vu+QLaJnBfh492EcS5Fe5WHAFVPTF6hjOmnz0Ed0Irl hHisM4eSTeEROJh/f59WigDFDGEW/G81/Z1kdQhIxLY0Xa1Mxp5+BiWj1aCFzJ7U81U2 SdkeLzG76O8jSNJrn9FjSWUlhZ+bj/O/HnnSjINf2hxfp1jRv6eR8S74ap4XQlZeKSXy biEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zpqh7kOk; 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 u17-20020a05620a431100b007456fa51212si10769805qko.250.2023.04.12.04.47.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Apr 2023 04:47:35 -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=zpqh7kOk; 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 1pmYtC-0004u9-Ud; Wed, 12 Apr 2023 07:43:50 -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 1pmYt6-0004k4-65 for qemu-devel@nongnu.org; Wed, 12 Apr 2023 07:43:44 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmYt1-0002NQ-Db for qemu-devel@nongnu.org; Wed, 12 Apr 2023 07:43:42 -0400 Received: by mail-wr1-x430.google.com with SMTP id e7so493582wrc.12 for ; Wed, 12 Apr 2023 04:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681299817; x=1683891817; 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=sZWSjtdLuqRfAHXhQ1Qn/4gxDZYp/Ml73FoJP/ry5BM=; b=zpqh7kOkoha8JhKb8g6iNhXDgtTC5gVB1VnvX3BxHnU+cYFLT6D2R1NFVydFAqm0yA eRGva3gmlWbKGZAPpDWsXHHKW4Gjw2p0PvqEEvwqgc1ND3q3IGkp0njS7U5Q1ClLZSy3 RiIVBc4JVY8wPe4h/YmX0VWygaRV9WTN3x8X1ISiJp54+rgNtN5SvlZ4qTNCMXyYarmq q6RcX0og6WA8/rDTOZA4C22iNXQIeZWWXnd/sfxE85VqwqpUX3vsufs8zea+IDSrey8g B6lwAKgtn31TkxxGoCjnA8KYd7eVHXQl1u1/91DbYh70K/2+Hk5kd+XUuPPeZYDw+o5v uz3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681299817; x=1683891817; 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=sZWSjtdLuqRfAHXhQ1Qn/4gxDZYp/Ml73FoJP/ry5BM=; b=kemPkLAtFYYdrPIfCypguYCUbjyGUyNjzYUS0RXW6SNCSmqeVKt2Q1QLnu8H1r7Y2f tZ8XELf0iyNJypi0RjaM63VaXVbT/wZYSCG7KyDquwUKmK+7lz8KYFXHcS+eK0GVEhDI Yia6pyp1xD4jVsi1ZZ1HuFtY5+wcJlFNAlFRoMFEfuFOzO1XXqH7scOthzKNnPSy9/T/ /wvcBXy2juG/gpaJgWq8PBxOE1RzHLABLrnBB1QV7cifKdEZ0yiY/koyKlRDgpPAwKlL ih7URfFuFgRVpVUvW2bL88EIXncxi/A8sjLPeV88hl/LNT267DzepXfpRVNF7neu60UI zZvw== X-Gm-Message-State: AAQBX9dS2WIdpMV8y/jYbSYsavGMWSrFEAqLuWsPjzc1B9QxJ3jPb3AI 9MasH7YWEDyBlO21jimYucWbv7MNln/3tqUCngwJ7cO6 X-Received: by 2002:a5d:4564:0:b0:2ef:ba74:44c2 with SMTP id a4-20020a5d4564000000b002efba7444c2mr1748824wrc.2.1681299817039; Wed, 12 Apr 2023 04:43:37 -0700 (PDT) Received: from stoup.hotel.gast (ip-037-024-010-236.um08.pools.vodafone-ip.de. [37.24.10.236]) by smtp.gmail.com with ESMTPSA id k9-20020a5d4289000000b002d21379bcabsm16980826wrq.110.2023.04.12.04.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 04:43:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, qemu-riscv@nongnu.org, LIU Zhiwei , Alistair Francis , Weiwei Li , Daniel Henrique Barboza Subject: [PATCH v7 02/25] target/riscv: Add a general status enum for extensions Date: Wed, 12 Apr 2023 13:43:10 +0200 Message-Id: <20230412114333.118895-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230412114333.118895-1-richard.henderson@linaro.org> References: <20230412114333.118895-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x430.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=unavailable 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: LIU Zhiwei The pointer masking is the only extension that directly use status. The vector or float extension uses the status in an indirect way. Replace the pointer masking extension special status fields with the general status. Reviewed-by: Richard Henderson Signed-off-by: LIU Zhiwei Message-Id: <20230324143031.1093-3-zhiwei_liu@linux.alibaba.com> [rth: Add a typedef for the enum] Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-3-richard.henderson@linaro.org> --- target/riscv/cpu.h | 8 ++++++++ target/riscv/cpu_bits.h | 12 ++++-------- target/riscv/cpu.c | 2 +- target/riscv/csr.c | 14 +++++++------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index aa53d0e256..ba11279716 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -97,6 +97,14 @@ enum { TRANSLATE_G_STAGE_FAIL }; +/* Extension context status */ +typedef enum { + EXT_STATUS_DISABLED = 0, + EXT_STATUS_INITIAL, + EXT_STATUS_CLEAN, + EXT_STATUS_DIRTY, +} RISCVExtStatus; + #define MMU_USER_IDX 3 #define MAX_RISCV_PMPS (16) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index a16bfaf43f..fb63b8e125 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -9,6 +9,9 @@ (((uint64_t)(val) * ((mask) & ~((mask) << 1))) & \ (uint64_t)(mask))) +/* Extension context status mask */ +#define EXT_STATUS_MASK 0x3ULL + /* Floating point round mode */ #define FSR_RD_SHIFT 5 #define FSR_RD (0x7 << FSR_RD_SHIFT) @@ -735,13 +738,6 @@ typedef enum RISCVException { #define PM_ENABLE 0x00000001ULL #define PM_CURRENT 0x00000002ULL #define PM_INSN 0x00000004ULL -#define PM_XS_MASK 0x00000003ULL - -/* PointerMasking XS bits values */ -#define PM_EXT_DISABLE 0x00000000ULL -#define PM_EXT_INITIAL 0x00000001ULL -#define PM_EXT_CLEAN 0x00000002ULL -#define PM_EXT_DIRTY 0x00000003ULL /* Execution enviornment configuration bits */ #define MENVCFG_FIOM BIT(0) @@ -781,7 +777,7 @@ typedef enum RISCVException { #define S_OFFSET 5ULL #define M_OFFSET 8ULL -#define PM_XS_BITS (PM_XS_MASK << XS_OFFSET) +#define PM_XS_BITS (EXT_STATUS_MASK << XS_OFFSET) #define U_PM_ENABLE (PM_ENABLE << U_OFFSET) #define U_PM_CURRENT (PM_CURRENT << U_OFFSET) #define U_PM_INSN (PM_INSN << U_OFFSET) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index fab38859ec..32c04214a1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -759,7 +759,7 @@ static void riscv_cpu_reset_hold(Object *obj) i++; } /* mmte is supposed to have pm.current hardwired to 1 */ - env->mmte |= (PM_EXT_INITIAL | MMTE_M_PM_CURRENT); + env->mmte |= (EXT_STATUS_INITIAL | MMTE_M_PM_CURRENT); #endif env->xl = riscv_cpu_mxl(env); riscv_cpu_update_mask(env); diff --git a/target/riscv/csr.c b/target/riscv/csr.c index f4d2dcfdc8..4268828dc4 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3534,7 +3534,7 @@ static RISCVException write_mmte(CPURISCVState *env, int csrno, /* hardwiring pm.instruction bit to 0, since it's not supported yet */ wpri_val &= ~(MMTE_M_PM_INSN | MMTE_S_PM_INSN | MMTE_U_PM_INSN); - env->mmte = wpri_val | PM_EXT_DIRTY; + env->mmte = wpri_val | EXT_STATUS_DIRTY; riscv_cpu_update_mask(env); /* Set XS and SD bits, since PM CSRs are dirty */ @@ -3614,7 +3614,7 @@ static RISCVException write_mpmmask(CPURISCVState *env, int csrno, if ((env->priv == PRV_M) && (env->mmte & M_PM_ENABLE)) { env->cur_pmmask = val; } - env->mmte |= PM_EXT_DIRTY; + env->mmte |= EXT_STATUS_DIRTY; /* Set XS and SD bits, since PM CSRs are dirty */ mstatus = env->mstatus | MSTATUS_XS; @@ -3642,7 +3642,7 @@ static RISCVException write_spmmask(CPURISCVState *env, int csrno, if ((env->priv == PRV_S) && (env->mmte & S_PM_ENABLE)) { env->cur_pmmask = val; } - env->mmte |= PM_EXT_DIRTY; + env->mmte |= EXT_STATUS_DIRTY; /* Set XS and SD bits, since PM CSRs are dirty */ mstatus = env->mstatus | MSTATUS_XS; @@ -3670,7 +3670,7 @@ static RISCVException write_upmmask(CPURISCVState *env, int csrno, if ((env->priv == PRV_U) && (env->mmte & U_PM_ENABLE)) { env->cur_pmmask = val; } - env->mmte |= PM_EXT_DIRTY; + env->mmte |= EXT_STATUS_DIRTY; /* Set XS and SD bits, since PM CSRs are dirty */ mstatus = env->mstatus | MSTATUS_XS; @@ -3694,7 +3694,7 @@ static RISCVException write_mpmbase(CPURISCVState *env, int csrno, if ((env->priv == PRV_M) && (env->mmte & M_PM_ENABLE)) { env->cur_pmbase = val; } - env->mmte |= PM_EXT_DIRTY; + env->mmte |= EXT_STATUS_DIRTY; /* Set XS and SD bits, since PM CSRs are dirty */ mstatus = env->mstatus | MSTATUS_XS; @@ -3722,7 +3722,7 @@ static RISCVException write_spmbase(CPURISCVState *env, int csrno, if ((env->priv == PRV_S) && (env->mmte & S_PM_ENABLE)) { env->cur_pmbase = val; } - env->mmte |= PM_EXT_DIRTY; + env->mmte |= EXT_STATUS_DIRTY; /* Set XS and SD bits, since PM CSRs are dirty */ mstatus = env->mstatus | MSTATUS_XS; @@ -3750,7 +3750,7 @@ static RISCVException write_upmbase(CPURISCVState *env, int csrno, if ((env->priv == PRV_U) && (env->mmte & U_PM_ENABLE)) { env->cur_pmbase = val; } - env->mmte |= PM_EXT_DIRTY; + env->mmte |= EXT_STATUS_DIRTY; /* Set XS and SD bits, since PM CSRs are dirty */ mstatus = env->mstatus | MSTATUS_XS;