[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC 3/8] target-arm: Add support for S2 page-tab
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH RFC 3/8] target-arm: Add support for S2 page-table protection bits |
Date: |
Thu, 1 Oct 2015 20:48:17 +0100 |
On 1 October 2015 at 19:44, Edgar E. Iglesias <address@hidden> wrote:
> On Wed, Sep 23, 2015 at 09:55:05AM -0700, Peter Maydell wrote:
>> This isn't right -- the XN bit controls executability and the
>> S2AP bits don't affect it at all. I think you want:
>>
>> int prot_rw = 0;
>> if (s2ap & 1) {
>> prot_rw |= PAGE_READ;
>> }
>> if (s2ap & 2) {
>> prot_rw |= PAGE_WRITE;
>> }
>> if (!xn) {
>> prot_rw |= PAGE_EXEC;
>> }
>
>
> Thanks, this was the stuff I was worried about when we talked about it
> last time. I've got the following now which seems to be the same as
> you suggest:
>
> static int get_S2prot(CPUARMState *env, int s2ap, int xn)
> {
> int prot;
>
> prot = s2ap & 1 ? PAGE_READ : 0;
> prot |= s2ap & 2 ? PAGE_WRITE : 0;
> if (!xn) {
> prot |= PAGE_EXEC;
> }
> return prot;
> }
Yep, that's the right logic, though it seems a bit odd not
to consistently use either 'if' or '?:' for all 3 bits.
thanks
-- PMM