From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21F4DC49EA5 for ; Thu, 24 Jun 2021 13:49:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ACDEA613C7 for ; Thu, 24 Jun 2021 13:49:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACDEA613C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwPj9-0002NN-Kw for qemu-devel@archiver.kernel.org; Thu, 24 Jun 2021 09:49:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwPiO-0001cs-Lr; Thu, 24 Jun 2021 09:48:20 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:41565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwPiN-00074j-5p; Thu, 24 Jun 2021 09:48:20 -0400 Received: by mail-ed1-x532.google.com with SMTP id n20so8613776edv.8; Thu, 24 Jun 2021 06:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=g1RgUFc5ffhIk6dEHmX4W19HtURzFLqX5YlhAIjwMZ8=; b=WH4sUcsLJakjV2GtpXp9dl0ja6CSecXdP0qv+LTxxqI3riBl9DDi+Sa77KjbvTo6wj wXmWchfPCP4uZYyHhqAZa1MLK0BYodMB9UDhgl1XjUp84bGPQT9PUykTbMdWjfFlOW0a r2K+wJtie27fL8Ce8d+V9/3rg43+mh6oYw3Vl3fPQVzquRHDnGPKG53jq1wsBzVIFQBW 064H/pL46DZrJc166p+U1QaXy1NECUvUp30sb3mV+QxvFX4zD3gmnjhwqE/aHkYPEpFv qGIn0+V9tvUT+YpKBj7JTH7j99KzqQcQ8hWmEAKPykhYVXyJUUyLaXkNNcsbvT+ROOOL ENWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=g1RgUFc5ffhIk6dEHmX4W19HtURzFLqX5YlhAIjwMZ8=; b=hVluQHUbH3kAyoCd1FYbDRyrjKEUjSiNw8dH7aWX/DXyyzwPTyiZThotqr8LZJ+C1P nndDL2DZ7o/CJvsnNsWkugRMq5KqlwP5JRNnh3B/+XPygFdTjcavBtKkdQKTJNDg7MLA WMDbr0egKvWiuzTUZb4S10kjs2++3BMxBCoLz7N6hCKQWkwZIL8cd5PIwTkG9nYcNWr3 LFTWW+ucbRXM+euYvqntBCACCOKR9PPui8N4GX9VdbRCtD03A8LS+rlNqtdo8rIqVyOc 6QPQ6RWasH2FiE4jXyoBHDq3L1GmI6OqZksBqaIDQMliogTHcuFQFYU0mQWuVSy+haWU 5oAQ== X-Gm-Message-State: AOAM533w8/JIYKemV4ewVlyvVolPaGOjL/1h4z3/U2r3dO+7t1WrXZoa WE/ICblIjCCbCMJOvGndShHIajYEu6Sf7zMdgDY= X-Google-Smtp-Source: ABdhPJwsaPS9eakf2uukNVbVqmYA1UfHZG3hZPlQqE/qoGg1sol+OHEzwqcK2w9ozbMHdBpHY7tAR/WXAOIlHbTGybA= X-Received: by 2002:aa7:c04d:: with SMTP id k13mr7313676edo.122.1624542496405; Thu, 24 Jun 2021 06:48:16 -0700 (PDT) MIME-Version: 1.0 References: <20210522155902.374439-1-josemartins90@gmail.com> In-Reply-To: From: Jose Martins Date: Thu, 24 Jun 2021 14:48:05 +0100 Message-ID: Subject: Re: [PATCH] target/riscv: hardwire bits in hideleg and hedeleg To: Alistair Francis Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=josemartins90@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:RISC-V TCG CPUs" , Sagar Karandikar , Bastian Koppelmann , "qemu-devel@nongnu.org Developers" , Alistair Francis , Palmer Dabbelt Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" > > +static const target_ulong vs_delegable_excps =3D delegable_excps & > > + ~((1ULL << (RISCV_EXCP_S_ECALL)) | > > > + (1ULL << (RISCV_EXCP_VS_ECALL)) | > > + (1ULL << (RISCV_EXCP_M_ECALL)) | > > These two are both read only 0, shouldn't they not be included in this li= st? > > > static int write_hedeleg(CPURISCVState *env, int csrno, target_ulong v= al) > > { > > - env->hedeleg =3D val; > > + env->hedeleg =3D val & vs_delegable_excps; > > Because we then allow a write to occur here. Note that the list is being bitwise negated, so both of these are actually not writable (ie read-only 0). There is still the question regarding the VS_ECALL (exception 10) bit raised by Zhiwei, since table 5.2 in the spec does not explicitly classify it. However, I believe it is safe to assume that exception 10 is non-delegable. Jos=C3=A9 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lwPiQ-0001el-N4 for mharc-qemu-riscv@gnu.org; Thu, 24 Jun 2021 09:48:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwPiO-0001cs-Lr; Thu, 24 Jun 2021 09:48:20 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:41565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwPiN-00074j-5p; Thu, 24 Jun 2021 09:48:20 -0400 Received: by mail-ed1-x532.google.com with SMTP id n20so8613776edv.8; Thu, 24 Jun 2021 06:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=g1RgUFc5ffhIk6dEHmX4W19HtURzFLqX5YlhAIjwMZ8=; b=WH4sUcsLJakjV2GtpXp9dl0ja6CSecXdP0qv+LTxxqI3riBl9DDi+Sa77KjbvTo6wj wXmWchfPCP4uZYyHhqAZa1MLK0BYodMB9UDhgl1XjUp84bGPQT9PUykTbMdWjfFlOW0a r2K+wJtie27fL8Ce8d+V9/3rg43+mh6oYw3Vl3fPQVzquRHDnGPKG53jq1wsBzVIFQBW 064H/pL46DZrJc166p+U1QaXy1NECUvUp30sb3mV+QxvFX4zD3gmnjhwqE/aHkYPEpFv qGIn0+V9tvUT+YpKBj7JTH7j99KzqQcQ8hWmEAKPykhYVXyJUUyLaXkNNcsbvT+ROOOL ENWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=g1RgUFc5ffhIk6dEHmX4W19HtURzFLqX5YlhAIjwMZ8=; b=hVluQHUbH3kAyoCd1FYbDRyrjKEUjSiNw8dH7aWX/DXyyzwPTyiZThotqr8LZJ+C1P nndDL2DZ7o/CJvsnNsWkugRMq5KqlwP5JRNnh3B/+XPygFdTjcavBtKkdQKTJNDg7MLA WMDbr0egKvWiuzTUZb4S10kjs2++3BMxBCoLz7N6hCKQWkwZIL8cd5PIwTkG9nYcNWr3 LFTWW+ucbRXM+euYvqntBCACCOKR9PPui8N4GX9VdbRCtD03A8LS+rlNqtdo8rIqVyOc 6QPQ6RWasH2FiE4jXyoBHDq3L1GmI6OqZksBqaIDQMliogTHcuFQFYU0mQWuVSy+haWU 5oAQ== X-Gm-Message-State: AOAM533w8/JIYKemV4ewVlyvVolPaGOjL/1h4z3/U2r3dO+7t1WrXZoa WE/ICblIjCCbCMJOvGndShHIajYEu6Sf7zMdgDY= X-Google-Smtp-Source: ABdhPJwsaPS9eakf2uukNVbVqmYA1UfHZG3hZPlQqE/qoGg1sol+OHEzwqcK2w9ozbMHdBpHY7tAR/WXAOIlHbTGybA= X-Received: by 2002:aa7:c04d:: with SMTP id k13mr7313676edo.122.1624542496405; Thu, 24 Jun 2021 06:48:16 -0700 (PDT) MIME-Version: 1.0 References: <20210522155902.374439-1-josemartins90@gmail.com> In-Reply-To: From: Jose Martins Date: Thu, 24 Jun 2021 14:48:05 +0100 Message-ID: Subject: Re: [PATCH] target/riscv: hardwire bits in hideleg and hedeleg To: Alistair Francis Cc: "qemu-devel@nongnu.org Developers" , "open list:RISC-V TCG CPUs" , Sagar Karandikar , Bastian Koppelmann , Alistair Francis , Palmer Dabbelt Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=josemartins90@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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-riscv@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2021 13:48:21 -0000 > > +static const target_ulong vs_delegable_excps =3D delegable_excps & > > + ~((1ULL << (RISCV_EXCP_S_ECALL)) | > > > + (1ULL << (RISCV_EXCP_VS_ECALL)) | > > + (1ULL << (RISCV_EXCP_M_ECALL)) | > > These two are both read only 0, shouldn't they not be included in this li= st? > > > static int write_hedeleg(CPURISCVState *env, int csrno, target_ulong v= al) > > { > > - env->hedeleg =3D val; > > + env->hedeleg =3D val & vs_delegable_excps; > > Because we then allow a write to occur here. Note that the list is being bitwise negated, so both of these are actually not writable (ie read-only 0). There is still the question regarding the VS_ECALL (exception 10) bit raised by Zhiwei, since table 5.2 in the spec does not explicitly classify it. However, I believe it is safe to assume that exception 10 is non-delegable. Jos=C3=A9