qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v3] target/riscv: update checks on writing pmpcfg for Smepmp
@ 2023-09-19  5:08 Chang Alvin
  2023-09-19  5:21 ` Alistair Francis
  0 siblings, 1 reply; 4+ messages in thread
From: Chang Alvin @ 2023-09-19  5:08 UTC (permalink / raw)
  To: Alistair Francis; +Cc: qemu-riscv, qemu-devel, alistair.francis, Andrew Jones

[-- Attachment #1: Type: text/plain, Size: 4564 bytes --]

 > -----Original Message-----

> From: Alistair Francis <alistair23@gmail.com>

> Sent: Tuesday, September 19, 2023 12:42 PM

> To: Alvin Che-Chia Chang(張哲嘉) <alvinga@andestech.com>

> Cc: qemu-riscv@nongnu.org; qemu-devel@nongnu.org;

> alistair.francis@wdc.com; ajones@ventanamicro.com

> Subject: Re: [PATCH v3] target/riscv: update checks on writing pmpcfg for

> Smepmp to version 1.0

>

> On Fri, Sep 15, 2023 at 6:32 PM Alvin Chang <alvinga@andestech.com> wrote:

> >

> > Current checks on writing pmpcfg for Smepmp follows Smepmp version

> > 0.9.1. However, Smepmp specification has already been ratified, and

> > there are some differences between version 0.9.1 and 1.0. In this

> > commit we update the checks of writing pmpcfg to follow Smepmp version

> > 1.0.

> >

> > When mseccfg.MML is set, the constraints to modify PMP rules are:

> > 1. Locked rules cannot be removed or modified until a PMP reset, unless

> >    mseccfg.RLB is set.

> > 2. From Smepmp specification version 1.0, chapter 2 section 4b:

> >    Adding a rule with executable privileges that either is M-mode-only

> >    or a locked Shared-Region is not possible and such pmpcfg writes are

> >    ignored, leaving pmpcfg unchanged.

> >

> > The commit transfers the value of pmpcfg into the index of the Smepmp

> > truth table, and checks the rules by aforementioned specification

> > changes.

> >

> > Signed-off-by: Alvin Chang <alvinga@andestech.com>

> > ---

> > Changes from v2: Adopt switch case ranges and numerical order.

> >

> > Changes from v1: Convert ePMP over to Smepmp.

>

> Did this part get lost?

>

> Alistair

>


Sorry, do you mean that the term "ePMP" should be changed to "Smepmp" in
source code?


Alvin Chang


> >

> >  target/riscv/pmp.c | 40 ++++++++++++++++++++++++++++++++--------

> >  1 file changed, 32 insertions(+), 8 deletions(-)

> >

> > diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index

> > a08cd95658..b144932b3b 100644

> > --- a/target/riscv/pmp.c

> > +++ b/target/riscv/pmp.c

> > @@ -99,16 +99,40 @@ static void pmp_write_cfg(CPURISCVState *env,

> uint32_t pmp_index, uint8_t val)

> >                  locked = false;

> >              }

> >

> > -            /* mseccfg.MML is set */

> > -            if (MSECCFG_MML_ISSET(env)) {

> > -                /* not adding execute bit */

> > -                if ((val & PMP_LOCK) != 0 && (val & PMP_EXEC) !=

> PMP_EXEC) {

> > +            /*

> > +             * mseccfg.MML is set. Locked rules cannot be removed or

> modified

> > +             * until a PMP reset. Besides, from Smepmp specification

> version 1.0

> > +             * , chapter 2 section 4b says:

> > +             * Adding a rule with executable privileges that either is

> > +             * M-mode-only or a locked Shared-Region is not possible

> and such

> > +             * pmpcfg writes are ignored, leaving pmpcfg unchanged.

> > +             */

> > +            if (MSECCFG_MML_ISSET(env) && !pmp_is_locked(env,

> pmp_index)) {

> > +                /*

> > +                 * Convert the PMP permissions to match the truth

> table in the

> > +                 * ePMP spec.

> > +                 */

> > +                const uint8_t epmp_operation =

> > +                    ((val & PMP_LOCK) >> 4) | ((val & PMP_READ) <<

> 2) |

> > +                    (val & PMP_WRITE) | ((val & PMP_EXEC) >> 2);

> > +

> > +                switch (epmp_operation) {

> > +                case 0 ... 8:

> >                      locked = false;

> > -                }

> > -                /* shared region and not adding X bit */

> > -                if ((val & PMP_LOCK) != PMP_LOCK &&

> > -                    (val & 0x7) != (PMP_WRITE | PMP_EXEC)) {

> > +                    break;

> > +                case 9 ... 11:

> > +                    break;

> > +                case 12:

> > +                    locked = false;

> > +                    break;

> > +                case 13:

> > +                    break;

> > +                case 14:

> > +                case 15:

> >                      locked = false;

> > +                    break;

> > +                default:

> > +                    g_assert_not_reached();

> >                  }

> >              }

> >          } else {

> > --

> > 2.34.1

> >

> >

[-- Attachment #2: Type: text/html, Size: 21024 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] target/riscv: update checks on writing pmpcfg for Smepmp
  2023-09-19  5:08 [PATCH v3] target/riscv: update checks on writing pmpcfg for Smepmp Chang Alvin
@ 2023-09-19  5:21 ` Alistair Francis
  2023-09-19  5:42   ` Himanshu Chauhan
  0 siblings, 1 reply; 4+ messages in thread
From: Alistair Francis @ 2023-09-19  5:21 UTC (permalink / raw)
  To: Chang Alvin; +Cc: qemu-riscv, qemu-devel, alistair.francis, Andrew Jones

On Tue, Sep 19, 2023 at 3:08 PM Chang Alvin <vivahavey@gmail.com> wrote:
>
>  > -----Original Message-----
>
> > From: Alistair Francis <alistair23@gmail.com>
>
> > Sent: Tuesday, September 19, 2023 12:42 PM
>
> > To: Alvin Che-Chia Chang(張哲嘉) <alvinga@andestech.com>
>
> > Cc: qemu-riscv@nongnu.org; qemu-devel@nongnu.org;
>
> > alistair.francis@wdc.com; ajones@ventanamicro.com
>
> > Subject: Re: [PATCH v3] target/riscv: update checks on writing pmpcfg for
>
> > Smepmp to version 1.0
>
> >
>
> > On Fri, Sep 15, 2023 at 6:32 PM Alvin Chang <alvinga@andestech.com> wrote:
>
> > >
>
> > > Current checks on writing pmpcfg for Smepmp follows Smepmp version
>
> > > 0.9.1. However, Smepmp specification has already been ratified, and
>
> > > there are some differences between version 0.9.1 and 1.0. In this
>
> > > commit we update the checks of writing pmpcfg to follow Smepmp version
>
> > > 1.0.
>
> > >
>
> > > When mseccfg.MML is set, the constraints to modify PMP rules are:
>
> > > 1. Locked rules cannot be removed or modified until a PMP reset, unless
>
> > >    mseccfg.RLB is set.
>
> > > 2. From Smepmp specification version 1.0, chapter 2 section 4b:
>
> > >    Adding a rule with executable privileges that either is M-mode-only
>
> > >    or a locked Shared-Region is not possible and such pmpcfg writes are
>
> > >    ignored, leaving pmpcfg unchanged.
>
> > >
>
> > > The commit transfers the value of pmpcfg into the index of the Smepmp
>
> > > truth table, and checks the rules by aforementioned specification
>
> > > changes.
>
> > >
>
> > > Signed-off-by: Alvin Chang <alvinga@andestech.com>
>
> > > ---
>
> > > Changes from v2: Adopt switch case ranges and numerical order.
>
> > >
>
> > > Changes from v1: Convert ePMP over to Smepmp.
>
> >
>
> > Did this part get lost?
>
> >
>
> > Alistair
>
> >
>
>
> Sorry, do you mean that the term "ePMP" should be changed to "Smepmp" in source code?

We still call it epmp to users and it's still marked as experimental.

See this line in the QEMU source:

MULTI_EXT_CFG_BOOL("x-epmp", epmp, false),

Alistair


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] target/riscv: update checks on writing pmpcfg for Smepmp
  2023-09-19  5:21 ` Alistair Francis
@ 2023-09-19  5:42   ` Himanshu Chauhan
  2023-09-19  9:27     ` Alistair Francis
  0 siblings, 1 reply; 4+ messages in thread
From: Himanshu Chauhan @ 2023-09-19  5:42 UTC (permalink / raw)
  To: Alistair Francis
  Cc: Chang Alvin, qemu-riscv, qemu-devel, alistair.francis,
	Andrew Jones



> On 19-Sep-2023, at 10:51 AM, Alistair Francis <alistair23@gmail.com> wrote:
> 
> On Tue, Sep 19, 2023 at 3:08 PM Chang Alvin <vivahavey@gmail.com> wrote:
>> 
>>> -----Original Message-----
>> 
>>> From: Alistair Francis <alistair23@gmail.com>
>> 
>>> Sent: Tuesday, September 19, 2023 12:42 PM
>> 
>>> To: Alvin Che-Chia Chang(張哲嘉) <alvinga@andestech.com>
>> 
>>> Cc: qemu-riscv@nongnu.org; qemu-devel@nongnu.org;
>> 
>>> alistair.francis@wdc.com; ajones@ventanamicro.com
>> 
>>> Subject: Re: [PATCH v3] target/riscv: update checks on writing pmpcfg for
>> 
>>> Smepmp to version 1.0
>> 
>>> 
>> 
>>> On Fri, Sep 15, 2023 at 6:32 PM Alvin Chang <alvinga@andestech.com> wrote:
>> 
>>>> 
>> 
>>>> Current checks on writing pmpcfg for Smepmp follows Smepmp version
>> 
>>>> 0.9.1. However, Smepmp specification has already been ratified, and
>> 
>>>> there are some differences between version 0.9.1 and 1.0. In this
>> 
>>>> commit we update the checks of writing pmpcfg to follow Smepmp version
>> 
>>>> 1.0.
>> 
>>>> 
>> 
>>>> When mseccfg.MML is set, the constraints to modify PMP rules are:
>> 
>>>> 1. Locked rules cannot be removed or modified until a PMP reset, unless
>> 
>>>>   mseccfg.RLB is set.
>> 
>>>> 2. From Smepmp specification version 1.0, chapter 2 section 4b:
>> 
>>>>   Adding a rule with executable privileges that either is M-mode-only
>> 
>>>>   or a locked Shared-Region is not possible and such pmpcfg writes are
>> 
>>>>   ignored, leaving pmpcfg unchanged.
>> 
>>>> 
>> 
>>>> The commit transfers the value of pmpcfg into the index of the Smepmp
>> 
>>>> truth table, and checks the rules by aforementioned specification
>> 
>>>> changes.
>> 
>>>> 
>> 
>>>> Signed-off-by: Alvin Chang <alvinga@andestech.com>
>> 
>>>> ---
>> 
>>>> Changes from v2: Adopt switch case ranges and numerical order.
>> 
>>>> 
>> 
>>>> Changes from v1: Convert ePMP over to Smepmp.
>> 
>>> 
>> 
>>> Did this part get lost?
>> 
>>> 
>> 
>>> Alistair
>> 
>>> 
>> 
>> 
>> Sorry, do you mean that the term "ePMP" should be changed to "Smepmp" in source code?
> 
> We still call it epmp to users and it's still marked as experimental.
> 
> See this line in the QEMU source:
> 
> MULTI_EXT_CFG_BOOL("x-epmp", epmp, false),
> 
> Alistair

I had sent a patch to rename epmp to Smepmp
https://www.mail-archive.com/qemu-devel@nongnu.org/msg967676.html


Regards
Himanshu




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] target/riscv: update checks on writing pmpcfg for Smepmp
  2023-09-19  5:42   ` Himanshu Chauhan
@ 2023-09-19  9:27     ` Alistair Francis
  0 siblings, 0 replies; 4+ messages in thread
From: Alistair Francis @ 2023-09-19  9:27 UTC (permalink / raw)
  To: Himanshu Chauhan
  Cc: Chang Alvin, qemu-riscv, qemu-devel, alistair.francis,
	Andrew Jones

On Tue, Sep 19, 2023 at 3:43 PM Himanshu Chauhan
<hchauhan@ventanamicro.com> wrote:
>
>
>
> > On 19-Sep-2023, at 10:51 AM, Alistair Francis <alistair23@gmail.com> wrote:
> >
> > On Tue, Sep 19, 2023 at 3:08 PM Chang Alvin <vivahavey@gmail.com> wrote:
> >>
> >>> -----Original Message-----
> >>
> >>> From: Alistair Francis <alistair23@gmail.com>
> >>
> >>> Sent: Tuesday, September 19, 2023 12:42 PM
> >>
> >>> To: Alvin Che-Chia Chang(張哲嘉) <alvinga@andestech.com>
> >>
> >>> Cc: qemu-riscv@nongnu.org; qemu-devel@nongnu.org;
> >>
> >>> alistair.francis@wdc.com; ajones@ventanamicro.com
> >>
> >>> Subject: Re: [PATCH v3] target/riscv: update checks on writing pmpcfg for
> >>
> >>> Smepmp to version 1.0
> >>
> >>>
> >>
> >>> On Fri, Sep 15, 2023 at 6:32 PM Alvin Chang <alvinga@andestech.com> wrote:
> >>
> >>>>
> >>
> >>>> Current checks on writing pmpcfg for Smepmp follows Smepmp version
> >>
> >>>> 0.9.1. However, Smepmp specification has already been ratified, and
> >>
> >>>> there are some differences between version 0.9.1 and 1.0. In this
> >>
> >>>> commit we update the checks of writing pmpcfg to follow Smepmp version
> >>
> >>>> 1.0.
> >>
> >>>>
> >>
> >>>> When mseccfg.MML is set, the constraints to modify PMP rules are:
> >>
> >>>> 1. Locked rules cannot be removed or modified until a PMP reset, unless
> >>
> >>>>   mseccfg.RLB is set.
> >>
> >>>> 2. From Smepmp specification version 1.0, chapter 2 section 4b:
> >>
> >>>>   Adding a rule with executable privileges that either is M-mode-only
> >>
> >>>>   or a locked Shared-Region is not possible and such pmpcfg writes are
> >>
> >>>>   ignored, leaving pmpcfg unchanged.
> >>
> >>>>
> >>
> >>>> The commit transfers the value of pmpcfg into the index of the Smepmp
> >>
> >>>> truth table, and checks the rules by aforementioned specification
> >>
> >>>> changes.
> >>
> >>>>
> >>
> >>>> Signed-off-by: Alvin Chang <alvinga@andestech.com>
> >>
> >>>> ---
> >>
> >>>> Changes from v2: Adopt switch case ranges and numerical order.
> >>
> >>>>
> >>
> >>>> Changes from v1: Convert ePMP over to Smepmp.
> >>
> >>>
> >>
> >>> Did this part get lost?
> >>
> >>>
> >>
> >>> Alistair
> >>
> >>>
> >>
> >>
> >> Sorry, do you mean that the term "ePMP" should be changed to "Smepmp" in source code?
> >
> > We still call it epmp to users and it's still marked as experimental.
> >
> > See this line in the QEMU source:
> >
> > MULTI_EXT_CFG_BOOL("x-epmp", epmp, false),
> >
> > Alistair
>
> I had sent a patch to rename epmp to Smepmp
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg967676.html

Thanks! That patch has some comments that need a v2. Do you mind sending a v2?

Alistair

>
>
> Regards
> Himanshu
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-19  9:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-19  5:08 [PATCH v3] target/riscv: update checks on writing pmpcfg for Smepmp Chang Alvin
2023-09-19  5:21 ` Alistair Francis
2023-09-19  5:42   ` Himanshu Chauhan
2023-09-19  9:27     ` Alistair Francis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).